如何使用 suexec、Apache 和 php CGi 调试解决 500 内部错误 aws micro ec2

如何使用 suexec、Apache 和 php CGi 调试解决 500 内部错误 aws micro ec2

我在 Ubuntu 12.04 上的 amazon micro ec2 上运行 WordPress 多站点,使用 suexec、Apache 和 php CGi,但是我遇到了很多内部服务器 500 错误,我正在调试它以找到解决方案。我在下面发布了我的错误日志

example.com 错误日志:

[Fri Oct 26 10:10:08 2012] [warn] [client 23.23.xxx.xx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Oct 26 10:10:08 2012] [error] [client 23.23.xxx.xx] Premature end of script headers: wp-cron.php
[Fri Oct 26 10:50:04 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: https://www.example.com/wp-admin/
[Fri Oct 26 10:50:04 2012] [error] [client 190.213.xxx.xxx] Premature end of script headers: admin.php, referer: https://www.example.com/wp-admin/
[Fri Oct 26 10:58:14 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 10:58:15 2012] [error] [client 190.213.xxx.xxx] Premature end of script headers: admin-ajax.php, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 10:58:56 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 10:58:57 2012] [error] [client 190.213.xxx.xxx] Premature end of script headers: plugins.php, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 10:59:18 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 10:59:18 2012] [error] [client 190.213.xxx.xxx] Premature end of script headers: admin-ajax.php, referer: https://www.example.com/wp-admin/network/index.php
[Fri Oct 26 11:01:49 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: https://www.example.com/wp-admin/
[Fri Oct 26 11:01:49 2012] [warn] [client 190.213.xxx.xxx] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function, referer: https://www.example.com/wp-admin/

Apache 日志:

php (pre-forking): Cannot allocate memory
php (pre-forking): Cannot allocate memory
Recipient names must be specified
Recipient names must be specified
php (pre-forking): Cannot allocate memory
php (pre-forking): Cannot allocate memory
php (pre-forking): Cannot allocate memory
[Fri Oct 26 10:49:33 2012] [warn] mod_fcgid: cleanup zombie process 2852
[Fri Oct 26 10:49:33 2012] [warn] mod_fcgid: cleanup zombie process 2851
[Fri Oct 26 10:49:33 2012] [warn] mod_fcgid: cleanup zombie process 2853
[Fri Oct 26 10:58:22 2012] [warn] mod_fcgid: process 2892 graceful kill fail, sending SIGKILL
php (pre-forking): Cannot allocate memory
[Fri Oct 26 10:59:21 2012] [warn] mod_fcgid: process 2894 graceful kill fail, sending SIGKILL
[Fri Oct 26 10:59:25 2012] [warn] mod_fcgid: process 2866 graceful kill fail, sending SIGKILL

suexec.log:

[2012-10-25 16:05:36]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 18:09:38]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 18:09:51]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 18:14:03]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 18:14:06]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 18:14:35]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 20:20:27]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 20:20:29]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 20:20:31]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 21:42:12]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-25 22:56:50]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 02:34:43]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 04:25:07]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 06:35:19]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 06:40:05]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 07:22:45]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 10:10:05]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 10:49:24]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi
[2012-10-26 10:49:24]: uid: (1002/username) gid: (1002/username) cmd: php-fcgi

根据日志,有人能确定是什么原因造成的吗?我想这可能是微型实例,我正在考虑将其升级为小型实例。

任何帮助将不胜感激。

这是输入 free -m 后的输出

             total       used       free     shared    buffers     cached
Mem:           590        583          6          0          2         22
-/+ buffers/cache:        559         30
Swap:            0          0          0

答案1

我从 Miro 实例升级到小型实例,这似乎解决了不再出现 500 错误的问题。

看来 Miro 实例没有足够的内存来有效地以一致的方式操作 WordPress Multi-Site。

答案2

如果您感觉服务器速度非常慢,您可以添加另一个 EBS 并将其用作交换。

否则,您可以尝试减少 php 内存限制(它在中设置php.ini),删除未使用的 php 扩展,或者迁移到更轻量级的版本,如 nginx+php-fpm。

相关内容