Tips:线上pfsense中添加bandwidthd监控流量的功能存在问题,需要配置一个支持php的web环境来进行支持,这里选择了nginx+php。

Environment

  • yum
1
wget http://mirrors.opencas.cn/epel/6/i386/epel-release-6-8.noarch.rpm
  • CentOS6.3_x64

Install software

  • Install nginx
1
2
3
4
5
6
7
8
9
yum install nginx
#GeoIP.x86_64 0:1.6.5-1.el6                                         
#GeoIP-GeoLite-data.noarch 0:2015.04-2.el6                          
#GeoIP-GeoLite-data-extra.noarch 0:2015.04-2.el6                    
#geoipupdate.x86_64 0:2.2.1-2.el6                                   
#libxslt.x86_64 0:1.1.26-2.el6_3.1                                  
#nginx-filesystem.noarch 0:1.0.15-12.el6
chkconfig nginx on
/etc/init.d/nginx restart
  • Install php-fpm
1
2
3
4
5
6
7
yum install php-fpm
#Installing : php-common-5.3.3-46.el6_6.x86_64                  1/2
#Installing : php-fpm-5.3.3-46.el6_6.x86_64                     2/2
#Verifying  : php-fpm-5.3.3-46.el6_6.x86_64                     1/2
#Verifying  : php-common-5.3.3-46.el6_6.x86_64                  2/2
chkconfig php-fpm on
/etc/init.d/php-fpm restart

Edit config

  • 备份配置文件
1
cp /etc/nginx/conf.d/default.conf /tmp/
  • 修改配置文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#vim /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  localhost;
    autoindex    on;
    #charset koi8-r;  
    #access_log  /var/log/nginx/log/host.access.log  main;  

    location / {
        root   /var/www/html;
        index  index.html index.htm index.php;
    }

    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
        include        fastcgi_params;
    }
    }    

Test

  • 需确认/var/www/html存在,在此目录下创建测试文件
1
2
3
4
#vim /var/www/html/index.php    #内容如下
<?php
           phpinfo();
       ?>
  • 从浏览器访问查看效果 url:IP