六、创建虚拟主机配置文件
- server
- {
- listen 80;
- server_name www.ie15.net;
- index index.php index.html index.htm default.html default.htm default.php;
- root /data/ie15/bbs;
- location ~ .*\.(php|php5)?$
- {
- fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location /status {
- stub_status on;
- access_log off;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- }
- location ~ .*\.(js|css)?$
- {
- expires 12h;
- }
- access_log off;
- }
vi /usr/local/nginx/conf/vhost/www.ie15.net.conf #添加以下内容
- server
- {
- listen 80;
- server_name www.ie15.net;
- index index.php index.html index.htm default.html default.htm default.php;
- root /data/ie15/sns;
- location ~ .*\.(php|php5)?$
- {
- fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location /status {
- stub_status on;
- access_log off;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- }
- location ~ .*\.(js|css)?$
- {
- expires 12h;
- }
- access_log off;
- }
七、测试
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信息