我今天发现相同php代码部署到
两台服务器上,有一台服务器的完全正常,但是另一台上有一个页面出现500错误,而其它页面是正常的错误:
- [root@operation5 ~]# curl -kvL --cookie "PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e" -H "HOST:test.com"
- * About to connect() to 1.1.1.1 port 80
- * Trying 1.1.1.1... connected
- * Connected to 1.1.1.1 (1.1.1.1) port 80
- > GET /admin/generatetest/id/1 HTTP/1.1
- > User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
- > Accept: */*
- > Cookie: PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e
- > HOST:test.com
- >
- < HTTP/1.0 500 Internal Server Error
- < Date: Thu, 26 Apr 2012 09:31:18 GMT
- < Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.4
- < X-Powered-By: PHP/5.2.4
- < Expires: Thu, 19 Nov 1981 08:52:00 GMT
- < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
- < Pragma: no-cache
- < Content-Length: 0
- < Connection: close
- < Content-Type: text/html; charset=utf-8
- * Closing connection #0
这两台服务器的前端是nginx代理,而这两台服务器上用的是apache
解决过程如下:
1.开始我怀疑是nginx的代理时间太短,因为这个页面的执行时间是1分半,于是改了,但是还是出现相同的错误
nginx修改为
- server 1.1.1.1 max_fails=2 fail_timeout=180s;
php.ini修改为300s
- max_execution_time = 300 ; Maximum execution time of each script, in seconds
2.在php里增加set_time_limit(0),还是一样
3.修改php文件权限为755,还是一样
4.最后怀疑是从数据库里读出的数据量太大,程序里取出的数据有将近2000条,超过php设置的最大内存数
于是把php.ini里的128M调到512M,访问变为200 ok
- memory_limit = 512M ; Maximum amount of memory a script may consume (128MB)
测试成功:
- [root@operation5 ~]# curl -kvL --cookie "PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e" -H "HOST:test.com"
- * About to connect() to 1.1.1.1 port 80
- * Trying 1.1.1.1... connected
- * Connected to 1.1.1.1 (1.1.1.1) port 80
- > GET /admin/generatetest/id/1 HTTP/1.1
- > User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
- > Accept: */*
- > Cookie: PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e
- > HOST:test.com
- >
- < HTTP/1.1 200 OK
- < Date: Thu, 26 Apr 2012 09:35:56 GMT
- < Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.4
- < X-Powered-By: PHP/5.2.4
- < Expires: Thu, 19 Nov 1981 08:52:00 GMT
- < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
- < Pragma: no-cache
- < Content-Length: 7
- < Content-Type: text/html; charset=utf-8
- Connection #0 to host 1.1.1.1 left intact
- * Closing connection #0
- success[root@operation5 ~]#
阅读(47831) | 评论(0) | 转发(0) |