眾所周知,nginx是一個輕量級且高性能的反向代理web服務器,如果nginx想搭建網(wǎng)絡環(huán)境,勢必是需要綁定域名的,那么,nginx怎么綁定域名,今天聚名企服為大家介紹下,希望能夠幫助到你~
nginx服務器綁定域名的詳細教程
1、打開nginx域名配置的文件目錄:/usr/local/nginx/conf/servers ,然后需要在這個目錄里面建立一個文件夾:y447.cn.conf,再在此文件里寫入相關規(guī)則:
server{
listen 80;
server_name y447.cn; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/juming.com; #網(wǎng)站根目錄
include juming.conf; #調用其他規(guī)則,也可去除
}
接著將服務器重啟,即可綁定成功。
2、一個文件多個域名的寫法;通常情況下添加多個域名的規(guī)則大多數(shù)是一樣的,只要將上面單個域名重復寫下來即可:按照下方步驟操作就行了
server{
listen 80;
server_name y447.cn; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/juming.com; #網(wǎng)站根目錄
includejuming.conf; #調用其他規(guī)則,也可去除
}
server{
listen 80;
server_name msn.juming.com; #綁定域名
index index.htm index.html index.php; #默認文件
root /home/www/msn.juming.com; #網(wǎng)站根目錄
include location.conf; #調用其他規(guī)則,也可去除
}
3、不帶3w的域名加301跳轉,這個和綁定域名是一樣的邏輯,不過要先綁定不帶3w的域名,不需要寫網(wǎng)站目錄,直接301跳轉就行了。
server
{
listen 80;
server_name juming.com;
rewrite ^/(.*) https://juming.com/$1 permanent;
}
以上就是nginx服務器綁定域名的詳細教程的相關介紹。