首页 > 其他 > 详细

Nginx多虚拟主机

时间:2021-07-30 09:12:42      阅读:29      评论:0      收藏:0      [点我收藏+]

环境准备

技术分享图片

 

 添加nginx的配置,添加多个server{}标签,让nginx支持基于ip的多虚拟主机,返回多个站点内容

给nginx添加include包含语法,让其他目录下的配置文件参数,导入到nginx.conf中,这样的写法,能够让nginx每一个配置文件,看起来更简洁

更清晰

修改nginx.conf,在http{}标签中的最后一行,添加如下参数,extra文件夹和nginx.conf文件夹为相对

include  extra/*.conf

在extra目录下,添加多个基于ip的虚拟主机配置

技术分享图片

 

 检查nginx语法是否正确

[root@localhost extra]# nginx -t
nginx: the configuration file /opt/nginx1.8/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx1.8/conf/nginx.conf test is successful

重新加载nginx 配置,改了较多的nginx配置,在允许重启的情况下

 

nginx -s  stop

准备站点内容

技术分享图片

 

 技术分享图片

 

Nginx基于多域名的虚拟主机配置

技术分享图片

 

 环境准备

在客户端本地修改hosts文件信息

 

Nginx多虚拟主机

原文:https://www.cnblogs.com/sprr/p/15077618.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!