我知道,有很多与此主题相关的问题,但出于某种原因,其他解决方案都不适合我。所以就是这样:
当我访问根文件夹中/dev/
包含 PHP 文件的子文件夹时,我得到的只是一个空白页,当我查看源代码时没有任何内容。
你知道为什么会发生这种事吗?
这是我的配置
/etc/php5/fpm/pool.d/www.conf
[www]
prefix = /var/log/php5-fpm/
user = marian
group = marian
listen = 127.0.0.1:9000
listen.backlog = 128
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 30
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.process_idle_timeout = 10s;
pm.max_requests = 500
pm.status_path = /status
ping.path = /ping
ping.response = pong
access.log = /var/log/php5-fpm/access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = slow.log
request_slowlog_timeout = 10s
request_terminate_timeout = 30s
rlimit_files = 131072
rlimit_core = 0
chdir = /
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/php5-fpm/error.log
php_admin_flag[log_errors] = on
/etc/nginx/sites-available/server.com
server {
listen 80;
root /home/marian/server.com;
index index.php index.html index.htm;
server_name server.com *.server.com;
error_log /home/marian/server.com/error.log notice;
access_log /home/marian/server.com/access.log main;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE AGP;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
try_files $uri = /index.php?$args;
fastcgi_intercept_errors on;
}
location ~* \.(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|ogg|mid|js|css|wml|swf|woff|ttf|html|htm)$ {
fastcgi_hide_header Set-Cookie;
gzip on;
#expires max;
#add_header Pragma public;
#add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#add_header Access-Control-Allow-Origin *;
}
location ~ /\.ht {
deny all;
}
}
更新:
日志中捕获的错误是:
rewrite or internal redirection cycle while internally redirecting to "/index.php", client: <IP>, server: server.comt, request: "GET /feed/ HTTP/1.1", host: "www.server.com"
index.php
但是我在根目录中没有,只是index.html
在子文件夹中没有发现任何错误/dev/
答案1
你的 try_files 语句看起来格式不正确。在/dev/?
当 nginx 收到请求时,您目前已将其设置为使用 catch-alllocation / {}
块。这意味着如果您转到
http://example.com/dev/
网络服务器将尝试查找 /dev/、/dev//,然后查找 /dev/index.php?example_arg=0以该顺序— 它将传递到第二个位置块。
如果没有 /dev/index.php,则说明你已经明确告知了 try_files 语句那里返回 /index.php?example_arg=0 — 而不是 404 或某些有用的信息。
我的猜测是,您的顶级 index.php 不知道如何处理您传递给它的参数,因此不返回任何内容。因此,页面空白,没有错误,没有错误。
编辑后:
故障排除 101很可能是你的 php 文件有问题,而不是 php-fpm 服务器有问题。我建议打开第二个终端进入你的主机,然后使用
tail -f /home/marian/server.com/access.log
您可以尝试访问您正在测试的页面并确定发生了什么。