nginx基于多端口的虚拟主机

开放80,81端口

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=81/tcp --permanent
firewall-cmd --reload

配置nginx

在html下新建文件夹duankou1,duankou2

vim nginx

server {
        listen 81;
        server_name localhost;

        location / {
           root html/duankou1;
           index index.html index.htm;
         }
    }
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html/duankou2;
            index  index.html index.htm;
        }

重启nginx

posted @ 2020-09-07 09:31  琴似蓝调  阅读(211)  评论(0编辑  收藏  举报