我刚刚安装了 nginx 和 php5-fpm,我想在端口 82 上测试它。所以我调用http://mysite.com:82/test555.php 但我什么也没看到。白屏而已。没有错误,没有警告,我什么也没看到:) 有 nginx 的错误日志和 php5-fpm 的错误日志 - 但是......没有任何错误。我不明白出了什么问题。请帮我找出来。
root@localhost:# echo "<?php phpinfo(); ?>" > /home/www/public_html/test555.php
root@localhost:# chmod 755 /home/www/public_html/test555.php
root@localhost:# cat /etc/nginx/sites-available/default
server {
listen 82;
root /home/www/public_html;
index index.php index.html;
server_name mysite.com;
access_log /var/log/nginx/nginx-access.com.log;
error_log /var/log/nginx/nginx-errors.com.log;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REMOTE_ADDR $remote_addr;
}
}
root@localhost:# /etc/init.d/nginx status
* nginx is running
root@localhost:# /etc/init.d/php5-fpm status
* php5-fpm is running
root@localhost:# ls -la /var/run/php5-fpm.sock
srw-rw-rw- 1 root root 0 Feb 3 01:14 /var/run/php5-fpm.sock
root@localhost:# cat /var/log/php5-fpm.log
....
[03-Feb-2014 01:14:52] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
[03-Feb-2014 01:14:52] NOTICE: fpm is running, pid 19080
[03-Feb-2014 01:14:52] NOTICE: ready to handle connections
root@localhost:# cat /var/log/nginx/nginx-access.com.log
...ip... - - [03/Feb/2014:01:29:44 +0000] "GET /test555.php HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0"
root@localhost:# cat /var/log/nginx/nginx-errors.com.log
root@localhost:#
Run Code Online (Sandbox Code Playgroud)
我接下来可以做什么来了解发生了什么?我看到它应该可以正常工作。PHP 脚本返回 code=200 但我没有看到输出。它从未被调用过,因为我试图在那里添加 file_put_contents 并且它真的从未被 nginx 调用过。
我今天使用的是完全升级的 ubuntu 12.04。
slm*_*slm 17
此 SO Q&A 听起来可能是您的问题,标题为:nginx 显示空白 PHP 页面。
你的location
节应该看起来像这样:
location ~ \.php$ {
include /path/to/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /path/to/www/dir$fastcgi_script_name;
}
Run Code Online (Sandbox Code Playgroud)
您必须特别注意您所引用的脚本的路径fastcgi_param
。
Adr*_*osa 13
这可能对面临此问题的其他人有用,
您还可以将以fastcgi_params
下行添加到您的 nginx conf 文件中,因此您无需指定变量的路径SCRIPT_FILENAME
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Run Code Online (Sandbox Code Playgroud)
特别是当您有许多虚拟主机时,这非常方便。
归档时间: |
|
查看次数: |
36920 次 |
最近记录: |