我是靠谱客的博主 机智煎蛋,这篇文章主要介绍在nginx中使用多域名访问项目,现在分享给大家,希望可以做个参考。

修改nginx的配置文件nginx.conf

vim /usr/local/nginx/conf/nginx.conf

一个server对象代表一个项目

server {
        listen       80;
        server_name  a.baidu.com;
		error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location / {
            root   /www/wwwroot/tp5;
            index  index.php index.html index.htm;
        }
}
server {
        listen       80;
        server_name  b.baidu.com;
		error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location / {
            root   /www/wwwroot/laravel;
            index  index.php index.html index.htm;
        }
    }


server对象中的server_name 表示你备案通过的域名
location对象中的root表示你的项目的路径
location对象中的index表示使用域名时的默认访问文件

最后

以上就是机智煎蛋最近收集整理的关于在nginx中使用多域名访问项目的全部内容,更多相关在nginx中使用多域名访问项目内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部