nginx配置改變默認訪問路徑


在安裝完nginx服務后,url訪問的默認路徑是安裝的路徑html文件夾下的內容,如果需要指定自定義的路徑,需要配置nginx.conf文件內容,這樣通過url訪問就可以了,比如: http://127.0.0.1/ 對應的物理路徑 c:/a/b/c

修改配置文件:

 

[html]  view plain  copy
 
 print?
  1. server {  
  2.   listen 80;  
  3.   server_name localhost;  
  4.   #charset koi8-r;  
  5.   #access_log logs/host.access.log main;  
  6.   location / {  
  7.     #這里設置你的實際路徑  
  8.     root /home/ftpuser/www/;   
  9.     index index.html index.htm;  
  10.     }  
  11. }  

 

重啟nginx再訪問,如果訪問提示 Nginx 403 Forbidden

需要在nginx.conf頭部加入一行

 

[html]  view plain  copy
 
 print?
  1. user root;  

 

重啟nginx再訪問,就可以正常訪問了


免責聲明!

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



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