我在CentOS 5机器上安装了带有PHP-FPM的nginx,但我很难让它为我的任何文件服务 - 无论是否PHP.
Nginx作为www-data:www-data运行,默认的"欢迎使用EPEL上的nginx"站点(由root拥有:具有644权限的root)加载正常.
nginx配置文件有/etc/nginx/sites-enabled/*.conf的include指令,我有一个配置文件example.com.conf,因此:
server {
listen 80;
Virtual Host Name
server_name www.example.com example.com;
location / {
root /home/demo/sites/example.com/public_html;
index index.php index.htm index.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /home/demo/sites/example.com/public_html$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
尽管public_html由www-data:www-data拥有2777文件权限,但该网站无法提供任何内容 -
[error] 4167#0: *4 open() "/home/demo/sites/example.com/public_html/index.html" failed (13: Permission denied), client: XX.XXX.XXX.XX, server: www.example.com, request: "GET /index.html HTTP/1.1", host: "www.example.com"
Run Code Online (Sandbox Code Playgroud)
我发现很多其他帖子的用户从nginx获得403s,但我见过的大部分都涉及使用Ruby/Passenger进行更复杂的设置(过去我实际上已成功)或者只是在上游PHP时收到错误-FPM参与其中,所以他们似乎没什么帮助.
我在这做过傻事吗?
使用nginx web服务器和php.nginx正在工作,我看到'欢迎来到nginx!' 但在尝试访问php页面时,我得到"访问被拒绝".我还安装了php-fastcgi.
这是我的nginx默认conf:
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params; …Run Code Online (Sandbox Code Playgroud)