我的服务器运行在 CentOS 6.3 + Nginx1.4.1 + PHP 5.3.3,</p>
nginx的默认配置是/etc/nginx/default.conf:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# 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 html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我在 /usr/share/nginx/html/phpinfo.php 上写了一个测试脚本
<?php
phpinfo();
?>
当我执行
curl localhost/phpinfo.php
它返回的php信息如下(部分):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse;}
.center {text-align: center;}
.center table { margin-left: auto; margin-right: auto; text-align: left;}
.center th { text-align: center !important; }
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
h1 {font-size: 150%;}
h2 {font-size: 125%;}
.p {text-align: left;}
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
.v {background-color: #cccccc; color: #000000;}
.vr {background-color: #cccccc; text-align: right; color: #000000;}
img {float: right; border: 0px;}
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
</style>
<title>phpinfo()</title><meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" /></head>
<body><div class="center">
<table border="0" cellpadding="3" width="600">
<tr class="h"><td>
<a href="http://www.php.net/"><img border="0" src="/phpinfo.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42" alt="PHP Logo" /></a><h1 class="p">PHP Version 5.3.3</h1>
</td></tr>
</table><br />
<table border="0" cellpadding="3" width="600">
<tr><td class="e">System </td><td class="v">Linux localhost.localdomain 2.6.32-358.el6.i686 #1 SMP Thu Feb 21 21:50:49 UTC 2013 i686 </td></tr>
<tr><td class="e">Build Date </td><td class="v">Feb 22 2013 02:38:57 </td></tr>
但是,当我在我的电脑上输入 ServerIP/phpinfo.php 时,浏览器无法打开该页面。我已经停止了iptables服务以排除防火墙的影响。
有谁知道如何解决这个问题?哪些错误日志可能会提供一些线索来帮助我找到原因?我已经阅读了 /var/log 上的 nginx 和 php-fpm 的错误日志,但没有任何想法。:-(
/var/log/php-fpm/error.log:
[05-Jun-2013 15:53:39] NOTICE: fpm is running, pid 19292
[05-Jun-2013 15:53:39] NOTICE: ready to handle connections
[05-Jun-2013 16:02:32] NOTICE: Terminating ...
[05-Jun-2013 16:02:32] NOTICE: exiting, bye-bye!
[05-Jun-2013 16:02:32] NOTICE: fpm is running, pid 19387
[05-Jun-2013 16:02:32] NOTICE: ready to handle connections
/var/log/php-fpm/www-error.log(部分):
[05-Jun-2013 16:37:54] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/share/nginx/html/index.php on line 2