关于lnmp绑定独立域名的问题
安装调试好军哥的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/;
....
}
想问一下:这样写对不对?哪个对?哪个更好?
谢谢 1更好,都行
页:
[1]