标准的 Wordpress 安装怎么会破坏 PHP?

标准的 Wordpress 安装怎么会破坏 PHP?

我正在尝试在 Ubuntu 14.04 上的标准 Apache 设置的根目录上托管一个 Wordpress 网站。该网站的主页加载正常,但任何其他页面都会导致浏览器中出现“未收到数据”消息,并且 Apache 日志中会出现段错误:

[Wed Sep 17 09:47:57.278168 2014] [core:notice] [pid 26097] AH00051: child pid 26123 exit signal Segmentation fault (11), possible coredump in /etc/apache2

我可以使用 gdb 附加到该进程,尝试加载链接页面,这就是我所看到的:

Program received signal SIGSEGV, Segmentation fault. _zend_mm_free_int (heap=0x7f7370b94920, p=0x7f735c138880) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_alloc.c:2104 2104 /build/buildd/php5-5.5.9+dfsg/Zend/zend_alloc.c: No such file or directory.

我已经加载了 Apache2 和 PHP5 的调试符号,这是回溯:

#0  _zend_mm_free_int (heap=0x7f7370b94920, p=0x7f735c138880) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_alloc.c:2104
#1  0x00007f736b4b7d55 in i_zval_ptr_dtor (zval_ptr=0x7f735c138880) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_execute.h:82
#2  zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:633
#3  0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108af0) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#4  0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#5  0x00007f736b4b8300 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f7370108960)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#6  0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108960) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#7  0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#8  0x00007f736b4b8300 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f7370108828)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#9  0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108828) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#10 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#11 0x00007f736b4b8300 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f7370108710)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#12 0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108710) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#13 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#14 0x00007f736b4b658c in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (execute_data=0x7f7370108600)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:30964
#15 0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108600) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#16 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#17 0x00007f736b4b8300 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f7370108480)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#18 0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108480) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#19 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#20 0x00007f736b4b8300 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f7370108370)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#21 0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108370) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#22 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#23 0x00007f736b4b658c in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (execute_data=0x7f7370108288)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:30964
#24 0x00007f736b4319e8 in execute_ex (execute_data=0x7f7370108288) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#25 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#26 0x00007f736b4b7241 in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (execute_data=0x7f73701081a0)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:8053
#27 0x00007f736b4319e8 in execute_ex (execute_data=0x7f73701081a0) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#28 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#29 0x00007f736b4b7241 in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (execute_data=0x7f73701080a0)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:8053
#30 0x00007f736b4319e8 in execute_ex (execute_data=0x7f73701080a0) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#31 0x00007f736b3f7b59 in dtrace_execute_ex (execute_data=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#32 0x00007f736b4095e0 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3)
    at /build/buildd/php5-5.5.9+dfsg/Zend/zend.c:1316
#33 0x00007f736b3a94c5 in php_execute_script (primary_file=primary_file@entry=0x7ffff71b7b40)
    at /build/buildd/php5-5.5.9+dfsg/main/main.c:2506
#34 0x00007f736b4b993a in php_handler (r=<optimized out>) at /build/buildd/php5-5.5.9+dfsg/sapi/apache2handler/sapi_apache2.c:667
#35 0x00007f7370269680 in ap_run_handler (r=0x7f7370093130) at config.c:169
#36 0x00007f7370269bc9 in ap_invoke_handler (r=r@entry=0x7f7370093130) at config.c:439
#37 0x00007f737027ec2c in ap_internal_redirect (new_uri=<optimized out>, r=<optimized out>) at http_request.c:644
#38 0x00007f7369abdcfc in handler_redirect (r=0x7f73700990a0) at mod_rewrite.c:5063
#39 0x00007f7370269680 in ap_run_handler (r=0x7f73700990a0) at config.c:169
#40 0x00007f7370269bc9 in ap_invoke_handler (r=r@entry=0x7f73700990a0) at config.c:439
#41 0x00007f737027f16a in ap_process_async_request (r=0x7f73700990a0) at http_request.c:317
#42 0x00007f737027f444 in ap_process_request (r=r@entry=0x7f73700990a0) at http_request.c:363
#43 0x00007f737027bf02 in ap_process_http_sync_connection (c=0x7f737009f290) at http_core.c:190
#44 ap_process_http_connection (c=0x7f737009f290) at http_core.c:231
#45 0x00007f7370272cc0 in ap_run_process_connection (c=0x7f737009f290) at connection.c:41
#46 0x00007f73702730a8 in ap_process_connection (c=c@entry=0x7f737009f290, csd=<optimized out>) at connection.c:202
#47 0x00007f736caaa767 in child_main (child_num_arg=child_num_arg@entry=5) at prefork.c:704
#48 0x00007f736caaa9a6 in make_child (s=0x7f73701d8de0, slot=5) at prefork.c:800
#49 0x00007f736caab60e in perform_idle_server_maintenance (p=<optimized out>) at prefork.c:902
#50 prefork_run (_pconf=<optimized out>, plog=<optimized out>, s=<optimized out>) at prefork.c:1090
#51 0x00007f737025069e in ap_run_mpm (pconf=0x7f7370206028, plog=0x7f73701d4028, s=0x7f73701d8de0) at mpm_common.c:96
#52 0x00007f7370249e36 in main (argc=3, argv=0x7ffff71b82e8) at main.c:777

首先,Zend 为什么要参与其中?我猜 PHP 就是这么构建的。我取消了 php5.ini 中引用它的一行的注释,但这并没有改变任何东西。

似乎相当清楚的是,在 Wordpress 网站中加载链接页面的调用会经过 mod_rewrite(理所当然),然后被交给 PHP,然后在一堆子调用中迷失,zend_vm_execute最终它似乎在寻找未安装的源文件。我需要在我的安装中安装 Zend 的其他部分吗?似乎我不应该为此安装非免费软件。

我是不是刚发现了一个错误?看来像安装普通的 Wordpress 这样简单的事情并不能发现潜在的问题。

唯一的问题是,我已将该网站从共享主机移至专用服务器。我使用了https://github.com/interconnectit/Search-Replace-DB解决 URL 的更改问题。一周前我设置并使用时,它还能正常工作,但现在却不行了。我查看了过去一周的所有日志,除了少量状态消息外什么都没有。自从它能正常工作以来,我没有安装任何东西或更改任何东西。今天早上我去更新网站,发现它坏了。

由于默认页面和仪表板正常工作,我使用 wp-admin 页面将永久链接配置改回默认配置,并将常用的 .htaccess 文件移开。另一个回溯显示 mod_rewrite 现在已退出循环,但问题仍然存在。

答案1

我在具有相当重主题的 Drupal 安装(Ubuntu 14,PHP-5.5.9)中发现了同样的错误。

显然,这些情况下,第一个怀疑点是 PHP 代码。但 gdb 没有给出任何有关自定义代码的提示,而是指向 zend_alloc.c,就像你的情况一样。

好的,似乎某些(忽略的)条件导致 Zend 引擎崩溃。

然后我开始研究 OPCache 配置,最后找到了原因。

就我的情况而言,安装有多个虚拟主机,最初启用了 OPCache,然后在一些虚拟主机中禁用......特别是在出现分段错误的那个虚拟主机中。

只需为特定的虚拟主机启用 OPCache,或者仅为整个安装禁用 OPCache,分段错误就会消失。

看起来,vhosts 之间的不同 OPcache 配置,加上一些(忽略的)PHP 条件,都导致了问题,尽管事实不应该如此。

如果能对此有所阐释的话我将非常感激...

相关内容