当我访问index.php时,它工作正常。 但是在localhost / pset7上,它给了403。
这里是权限日志,
-rw-r--r--. 1 root root 51 Jul 31 14:21 index.html -rw-r--r--. 1 root root 51 Jul 31 14:15 index.php drwxrwxr-x. 5 my_user my_user 4096 Jul 31 15:13 pset7
我需要在networking服务器上运行它,所以请告诉我如何设置正确的权限并解决此问题。
在CentOS上使用LEMP。
如果你需要任何其他信息/日志,只要问。
Edit1,nginx config- http://pastebin.com/K3fcWgec
谢谢。
发生这种情况的原因是nginx默认不允许列出目录内容。
所以,如果nginx找不到index目录下指定的文件,将会返回403错误码。
如果您想允许目录列表,您可以在configuration块中使用autoindex指令:
location /pset7 { autoindex on; }
你也应该把你的root和index指令从location /块移到server级别,这样你的configuration看起来就像这样:
server { listen 80; server_name localhost; root /var/www/html; index index.html index.htm index.php; location /pset7 { autoindex on; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
你看到这个的原因是,“pset7”没有被添加到Nginxconfiguration中。 您只需将以下内容添加到您的Nginxconfiguration中
location /pset7 { root /var/www/html; # Put this somewhere else, probably in the beginning of your config instead of here, if possible. index index.html index.htm index.php; }