一 端口方式:
第一步:编辑/usr/local/nginx/conf/nginx.conf文件
第二步:复制 server一份。(在复制之确认上传了一个新的静态项目。)
第三步:修改端口和第一份保持不一样,修改local/root的为新文件的名字:
第四步:重启nginx。
自己上传几个页面尝试一下,目录结构如下:
具体配置如下:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
} #原本的是这个样子的端口80跟目录为html,首页为index.html
server {
listen 81;
server_name localhost;
location / {
root cart;
index cart.html;
}
}
server {
listen 82;
server_name localhost;
location / {
root search;
index search.html;
}
}
二 域名方式:
第一步修改本机hosts:
192.168.40.131 cart.*****.com
192.168.40.131 search.*****.com
第二步:修改Linux中nginx的配置文件:nginx.conf:
端口都改80
修改各个:
第一个server中server_name : cart.*****.com
第二个server中server_name : search.*****.com
第三步重启nginx:./nginx -s reload
第四步测试
浏览器输入 cart.*****.com,search.*****.com。