VPS侦探论坛

 找回密码
 注册
查看: 4883|回复: 1

关于lnmp绑定独立域名的问题

[复制链接]
发表于 2012-2-29 21:30:23 | 显示全部楼层 |阅读模式

安装调试好军哥的lnmp。下一步就是绑定域名:
网站没有二级域名,就一个站,一个域名,目标:aaa.com和www.aaa.com都能正常访问网站。查询资料应该这样:

修改:/usr/local/nginx/conf/nginx.conf
因为一个域名包含两个:www.aaa.com 和不带www的:aaa.com
这里我想到了两种方法:
一:用一个server,把两个域名用空格分开,写在一起:
server
{
  listen       80;
  server_name www.aaa.com aaa.com;
  index index.html index.htm index.php;
  root  /home/wwwroot/;
     ....
}

二:在nginx.conf里,写两个server,把两个域名各写一个server,:
server
{
  listen       80;
  server_name www.aaa.com ;
  index index.html index.htm index.php;
  root  /home/wwwroot/;
     ....
}

server
{
  listen       80;
  server_name aaa.com ;
  index index.html index.htm index.php;
  root  /home/wwwroot/;
     ....
}

想问一下:这样写对不对?哪个对?哪个更好?

谢谢
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-3-1 09:08:05 | 显示全部楼层


1更好,都行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-22 11:31 , Processed in 0.024862 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表