Linux 下nginx 配置/绑定域名

2019-03-06  本文已影响2人  Hi小胡

1. 配置文件(/etc/nginx/conf.d/**.conf)

server
{
    listen   80;                            #监听端口设为 80。
    server_name  www.hlz.space;         #绑定您的域名。
    index index.htm index.html index.php;   #指定默认文件。
    root /var/www/html/hlzspace;           #指定网站根目录。
    include location.conf;                  #当您需要调用其他配置文件时才粘贴此项,如无需要,请删除此项。
}
server
{
    listen   80;                            #监听端口设为 80。
    server_name  www.hlz.space;         #绑定您的域名。
    index index.htm index.html index.php;   #指定默认文件。
    root /var/www/html/hlzspace;           #指定网站根目录。
    include location.conf;                  #当您需要调用其他配置文件时才粘贴此项,如无需要,请删除此项。
}
server
{
    listen   80;                            #监听端口设为 80。
    server_name  www.hlz2.space;         #绑定您的域名。
    index index.htm index.html index.php;   #指定默认文件。
    root /var/www/html/hlz2space;           #指定网站根目录。
    include location.conf;                  #当您需要调用其他配置文件时才粘贴此项,如无需要,请删除此项。
}
server
{
    listen 80;
    server_name hlz.space;
    rewrite ^/(.*) http://www.hlz.space/$1 permanent;
}
server
{
    listen   80;                            #监听端口设为 80。
    server_name  www.hlz.space;         #绑定您的域名。
    index index.htm index.html index.php;   #指定默认文件。
    root /var/www/html/hlzspace;           #指定网站根目录。
    include location.conf;                  #当您需要调用其他配置文件时才粘贴此项,如无需要,请删除此项。
    error_page 404              #/404.html;
}

2. 重启nginx

$ service nginx  restart
上一篇 下一篇

猜你喜欢

热点阅读