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}


未经允许请勿转载:程序喵 » Nginx多域名站点配置

点  赞 (0) 打  赏
分享到: