首页 > 其他 > 详细

Nginx配置特定二级域名

时间:2017-01-19 01:19:57      阅读:287      评论:0      收藏:0      [点我收藏+]

首先把先在域名设置页面把二级域名解析到服务器的公网IP上,这里假设是 bbs.domainname.com

然后编辑 /etc/nginx/sites-available/domain.com.conf 文件

增加以下代码,做多站点配置

server{
    listen 80;
    server_name bbs.domainname.com;
    root /var/www/html/bbs;
    index index.php index.html index.htm index.nginx-debian.html;
    
    location / {
        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    
    location = /50x.html {
        root /var/www/html/bbs;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

然后重新加载配置就可以了

service nginx reload

 

Nginx配置特定二级域名

原文:http://www.cnblogs.com/deali/p/6298352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!