Nginx前端和wp-admin / admin-ajax.php:debugging500个错误

每个小时左右,我开始在wp-admin和wp-admin / admin-ajax.php上得到500个错误。 我运行DSO + APC + Nginx(admin)+ Apache。 Apache在8080端口和Nginx上运行。

我到目前为止所做的:

  1. 我开始研究debug.log,并照顾一些不时发生的致命的崩溃
  2. 我添加了0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client因为我的日志显示tmp inode全部用完并崩溃nginx
  3. 检查其他问题,并将PHP memory_limit提高到128M
  4. 出于某种原因,我的wp-admin文件夹被分配给用户1001,我将其更改回nobody:nobody(nginx当前以nobody身份运行)

我正在为Nginx前端使用以下vhostsconfiguration:

 # BEGIN W3TC Page Cache cache location ~ /wp-content/cache/page_enhanced.*html$ { add_header Vary "Accept-Encoding, Cookie"; add_header Pragma "no-cache"; add_header Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"; } location ~ /wp-content/cache/page_enhanced.*gzip$ { gzip off; types {} default_type text/html; add_header Vary "Accept-Encoding, Cookie"; add_header Pragma "no-cache"; add_header Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"; add_header Content-Encoding gzip; } # END W3TC Page Cache cache # BEGIN W3TC Page Cache core #set $w3tc_rewrite 1; set $w3tc_rewrite ""; if ($request_method = POST) { set $w3tc_rewrite 0; } if ($query_string != "") { set $w3tc_rewrite 0; } if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") { set $w3tc_rewrite 0; } if ($http_user_agent ~* "(W3\ Total\ Cache/0\.9\.4)") { set $w3tc_rewrite 0; } if ($http_cookie ~* "(w3tc_preview)") { set $w3tc_rewrite _preview; } set $w3tc_enc ""; if ($http_accept_encoding ~ gzip) { set $w3tc_enc _gzip; } set $w3tc_ext ""; if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc") { set $w3tc_ext .html; } if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.xml$w3tc_enc") { set $w3tc_ext .xml; } if ($w3tc_ext = "") { set $w3tc_rewrite 0; } #if ($w3tc_rewrite = 1) { if ($w3tc_rewrite != 0) { rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite$w3tc_ext$w3tc_enc" last; } # END W3TC Page Cache core 

我在这里排除wp-admin – 可能的罪魁祸首?

  # Don't cache uris containing the following segments if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-location$ set $cache_uri 'null cache'; } location / { error_page 405 = @backend; add_header X-Cache "HIT from Backend"; proxy_pass http://backend:8080; include proxy.inc; include microcache.inc; } 

临时解决方法是重新启动nginx。 我正在使用一个简单的nginx.conf。

虽然我没有把它缩小,但是我想在这里做一个有根据的猜测。

最有可能的事情,帮助我解决这个问题:

  • 1)将PHP config和wp-config.php中的memory_limit设置为256.甚至可以尝试512,尽pipe这可能会导致其他问题。 我的假设是,我的一个MySQL查询是非常资源饥渴,我还没有优化,它可能已经造成了这个问题,这是显而易见的/mysql/slow.log(您可能需要打开慢SQLlogging首先在/etc/my.cnf中
  • 2)打开debug.log和debugging任何关键的错误不言而喻
  • 3)解决Nginx的IP冲突,检查你的虚拟主机
  • 4)白名单admin_ajax.php在mod_security(删除一些规则)你可以谷歌各种规则,可能会导致问题,虽然我觉得不太可能会抛出一个502.如果是modsec,它会扔403或40倍

我应该再次遇到这个问题,或者我find根本原因,我会再次更新