1、在/usr/local/nginx/conf/vhost
目录下新建响应配置文件,如 test.conf,并重新启动nginx
后缀名一定是 .conf
才可以被nginx识别到
域名 serve_name
为 175.27.158.137
端口 listen
为 9090
位置 root
为 /home/wwwroot/test
访问地址为 175.27.158.137:9090
server {
listen 9090;
server_name 175.27.158.137;
root /home/wwwroot/test;
location ~ .*\.(php|php5)?$
{
fastcgi_intercept_errors on;
#try_files $uri =404;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /
{
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location /status
{
#stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
2、在 /home/wwwroot/test 目录下新建 index.html 和 test.php