Nginx多域名站点配置

Nginx的多域名配置很简单,废话不多说,直接贴示例代码

Nginx服务器,允许建立多个Server节点,每个节点可以监听一个80端口,这样每个server下的location就可以指定一个新的项目地址

server {
        listen       80;
        server_name  a.com alias www.a.com;
        
        location / {
            root   D:/website/UPUPW_NP7.0/vhosts/a.com;
            index  index.html index.php ;
        }
        autoindex off;

        location ~ ^.+\.php {
            root           D:/website/UPUPW_NP7.0/vhosts/a.com;
            fastcgi_pass   bakend;
            fastcgi_index  index.php;
			fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
			fastcgi_param  PATH_INFO $fastcgi_path_info;
			fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
            include        fastcgi.conf;
        }
}
#server a.com end}

server {
        listen       80;
        server_name  b.com alias www.b.com;
        
        location / {
            root   D:/website/UPUPW_NP7.0/vhosts/b.com;
            index  index.html index.php ;
        }
        autoindex off;

        location ~ ^.+\.php {
            root           D:/website/UPUPW_NP7.0/vhosts/b.com;
            fastcgi_pass   bakend;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
            fastcgi_param  PATH_INFO $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
            include        fastcgi.conf;
        }
}
#server b.com end}


赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏