Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4178896
  • 博文数量: 291
  • 博客积分: 8003
  • 博客等级: 大校
  • 技术积分: 4275
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-30 18:28
文章分类

全部博文(291)

文章存档

2017年(1)

2013年(47)

2012年(115)

2011年(121)

2010年(7)

分类: 系统运维

2012-04-26 17:38:59

我今天发现相同php代码部署到两台服务器上,有一台服务器的完全正常,但是另一台上有一个页面出现500错误,而其它页面是正常的
错误:

点击(此处)折叠或打开

  1. [root@operation5 ~]# curl -kvL --cookie "PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e" -H "HOST:test.com"
  2. * About to connect() to 1.1.1.1 port 80
  3. * Trying 1.1.1.1... connected
  4. * Connected to 1.1.1.1 (1.1.1.1) port 80
  5. > GET /admin/generatetest/id/1 HTTP/1.1
  6. > 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
  7. > Accept: */*
  8. > Cookie: PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e
  9. > HOST:test.com
  10. >
  11. < HTTP/1.0 500 Internal Server Error
  12. < Date: Thu, 26 Apr 2012 09:31:18 GMT
  13. < Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.4
  14. < X-Powered-By: PHP/5.2.4
  15. < Expires: Thu, 19 Nov 1981 08:52:00 GMT
  16. < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  17. < Pragma: no-cache
  18. < Content-Length: 0
  19. < Connection: close
  20. < Content-Type: text/html; charset=utf-8
  21. * Closing connection #0

这两台服务器的前端是nginx代理,而这两台服务器上用的是apache
解决过程如下:
1.开始我怀疑是nginx的代理时间太短,因为这个页面的执行时间是1分半,于是改了,但是还是出现相同的错误
nginx修改为

点击(此处)折叠或打开

  1. server 1.1.1.1 max_fails=2 fail_timeout=180s;

php.ini修改为300s

点击(此处)折叠或打开

  1. 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

点击(此处)折叠或打开

  1. memory_limit = 512M ; Maximum amount of memory a script may consume (128MB)

测试成功:

点击(此处)折叠或打开

  1. [root@operation5 ~]# curl -kvL --cookie "PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e" -H "HOST:test.com"
  2. * About to connect() to 1.1.1.1 port 80
  3. * Trying 1.1.1.1... connected
  4. * Connected to 1.1.1.1 (1.1.1.1) port 80
  5. > GET /admin/generatetest/id/1 HTTP/1.1
  6. > 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
  7. > Accept: */*
  8. > Cookie: PHPSESSID=6da651d4a9aa8bdef463cf3580586c2e
  9. > HOST:test.com
  10. >
  11. < HTTP/1.1 200 OK
  12. < Date: Thu, 26 Apr 2012 09:35:56 GMT
  13. < Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.4
  14. < X-Powered-By: PHP/5.2.4
  15. < Expires: Thu, 19 Nov 1981 08:52:00 GMT
  16. < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  17. < Pragma: no-cache
  18. < Content-Length: 7
  19. < Content-Type: text/html; charset=utf-8
  20. Connection #0 to host 1.1.1.1 left intact
  21. * Closing connection #0
  22. success[root@operation5 ~]# 

阅读(47758) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~