Nginx配置特定二級域名


首先把先在域名設置頁面把二級域名解析到服務器的公網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

 

博客原文地址:http://blog.deali.cn/?p=832

我的微信公眾號:DealiAxy


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM