我刚刚完成了一个centos 7服务器的设置。 我用nginx和apache都安装了PHP 7。 我正在根据需求进行testing。
当我使用Apache时,一切运行正常。
当我使用nginx时,所有的静态内容也可以正常工作。
尝试使用PHP时,所有小内容都可以正常工作。 当有一些大的内容,如phpinfo()或一个大的SQL SELECT的输出,脚本失败没有任何错误(浏览器说没有数据)。
我检查了nginx日志,它说一些打开()到php-fpm失败,因为访问被拒绝,但我没有看到任何错误,两个进程运行相同的uid(apache)。
可能是一些超时问题? 如果没有,还有什么? 添加configuration(example.com是服务器)
user apache; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; index index.php index.html index.htm; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; # listen [::]:80 default_server; server_name examplecom www.examplecom; root /var/www/example.com/; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
2017/01/07 15:15:38 [crit] 5343#0: *60 open() "/var/lib/nginx/tmp/fastcgi/1/01/0000000011" failed (13: Permission denied) while reading upstream, client: 176.92.90.252, server: example.com, req uest: "GET /adminer.php?sqlite=.... HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com", referrer: "https://www.example.com/adminer.php?...."
php-fpmconfiguration不变(/etc/php-fpm.conf和/etc/php-fpm.d/www.conf不变)。
谢谢。
由于您以用户apache身份运行nginx ,因此您无权访问具有0700访问权限的/var/lib/nginx/ ,并由用户nginx拥有。
所以最好再次运行nginx作为用户nginx ,并相应地改变你的www root的访问权限。 否则,你将不得不改变可能被更新覆盖的/var/lib/nginx的所有者,它只是感觉不对。