Nginx如何新增绑定域名

2016-01-04 17:03:32 2155

nginx基于主机头值(绑定域名)是用 server_name来控制,需要新增域名绑定 只要修改相关字段的值即可。

linux下

首先打开nginx域名配置文件存放目录:/usr/local/nginx/conf/servers ,如要新增绑定域名bind.landui.com 

我们看下一个虚拟主机配置实例:


server
 {
 listen       80;
 server_name www.landui.com;             #绑定域名
index index.htm index.html index.php; #默认文件
root /home/www/web;               #网站根目录
include location.conf;                            #调用其他规则
}


修改 server_name字段为  server_name www.landui.com bind.landui.com;  

然后保存即可。


server
 {
 listen       80;
 server_name www.landui.com bind.landui.com;             #绑定域名
index index.htm index.html index.php;  #默认文件
root /home/www/web;               #网站根目录
include location.conf;                            #调用其他规则
}


然后重起nginx服务器,域名就绑定成功了
nginx服务(www.landui.com)器重起命令:/etc/init.d/nginx restart

nginx支持平滑重启 /etc/init.d/nginx reload 即可生效。

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: