六、创建虚拟主机配置文件

 

  1. server 
  2.         { 
  3.                 listen       80; 
  4.                 server_name www.ie15.net
  5.                 index index.php index.html index.htm default.html default.htm default.php; 
  6.                 root  /data/ie15/bbs; 
  7. location ~ .*\.(php|php5)?$ 
  8.                         { 
  9.                                 fastcgi_pass  unix:/tmp/php-cgi.sock; 
  10.                                 fastcgi_index index.php; 
  11.                                 include fcgi.conf; 
  12.                         } 
  13.                 location /status { 
  14.                         stub_status on
  15.                         access_log   off
  16.                 } 
  17.   
  18.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  19.                         { 
  20.                                 expires      30d; 
  21.                         } 
  22.                 location ~ .*\.(js|css)?$ 
  23.                         { 
  24.                                 expires      12h; 
  25.                         } 
  26.   
  27.                 access_log off
  28.         } 

vi  /usr/local/nginx/conf/vhost/www.ie15.net.conf  #添加以下内容

  1. server 
  2.         { 
  3.                 listen       80; 
  4.                 server_name www.ie15.net
  5.                 index index.php index.html index.htm default.html default.htm default.php; 
  6.                 root  /data/ie15/sns; 
  7. location ~ .*\.(php|php5)?$ 
  8.                         { 
  9.                                 fastcgi_pass  unix:/tmp/php-cgi.sock; 
  10.                                 fastcgi_index index.php; 
  11.                                 include fcgi.conf; 
  12.                         } 
  13.                 location /status { 
  14.                         stub_status on
  15.                         access_log   off
  16.                 } 
  17.   
  18.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  19.                         { 
  20.                                 expires      30d; 
  21.                         } 
  22.                 location ~ .*\.(js|css)?$ 
  23.                         { 
  24.                                 expires      12h; 
  25.                         } 
  26.   
  27.                 access_log off
  28.         } 

七、测试

vi /data/ie15/bbs/index.php  #新建文件,添加以下内容 <?php phpinfo(); ?> :wq! #保存退出

vi /data/ie15/sns/index.php  #新建文件,添加以下内容 <?php phpinfo(); ?> :wq! #保存退出

/etc/rc.d/init.d/nginx restart     #重启nginx

/etc/rc.d/init.d/php-fpm restart   #重启php-fpm

http://www.ie15.net:

phpinfo信息