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再访问,就可以正常访问了

原文地址:https://www.cnblogs.com/lidabo/p/7306781.html