1 .创建万维网(/home /万维网)
创建另一个wwwroot/test/index.html (站点目录)
创建vhost文件(/usr/local/nginx/conf/vhost )
配置和加入nginx.conf:include vhost/*.conf;
http{ …… .
include vhost/*.conf; //注意这里放在http{}里而不是外面
}
服务器{
listen80
server _ name test.zhouzhongjie.com;
根/家庭/万维网/测试;
index index.htmlindex.htm index.PHP;
#自动索引on;
}
fastcgi_index index.php;
fastcgi _ param script _ filename $ document _ root $ fastcgi _ script _ name;
包括fastcgi _ params;
}
}
server_name :下划线、域名、ip和localhost
server_name: _
server_name: xxx.com
服务器_ name : 22.22.22.22
server_name:localhost //
服务器
{
listen8001; #listen [:]:80;
server_name localhost;
index index.htmlindex.htm index.PHP default.html default.htm default.PHP;
根/home/wwwrooot/test; #include other.conf;
#error_page 404 /404.html;
# denyaccesstophpfilesinspecificdirectory
# location~/(WP-content ) uploads (/. *.PHP $ { deny all; }
#include enable-php.conf;
{
expires 30d;
}
{
expires 12h;
}
全部全部全部;
}
丹尼阿尔尔;
}
访问_ log off;
}
更改配置文件后,需要重新加载
./nginx-s重新加载