Mac自制软件apache 2.2 php5_模块分段故障


Mac homebrew apache 2.2 php5_module segmentation fault

我一直在将我的apache实现从Mac的内置apache转移到使用自制软件安装的apache。这一切进展顺利,但当我去测试我的PHP驱动的网站时,很明显PHP没有运行(apache本身工作并提供HTML,但PHP只是以纯文本形式存在于源代码中)。

我意识到我还没有在apache中启用Homebrew的apache php5_模块,所以我添加了:

LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so

到我的httpd.conf文件。我重新启动了apache,然后事情变得非常有趣:

$ sudo apachectl graceful
httpd not running, trying to start
(48)Address already in use: make_sock: could not bind to address [::]:80
/usr/local/bin/apachectl: line 78: 77225 Segmentation fault: 11  $HTTPD -k $ARGV

在那之后,我的测试站点完全消失了,注释php5_module行会返回HTML页面,但显然没有使用PHP。有人知道这是怎么发生的,或者如何解决吗?我看到了一些对mod_perl错误的引用,但我没有启用它。(我也不知道端口问题如何与此相关。)

此外,将mod_php5的路径更改为libexec/apache2/libphp5.so同样无效。

$ sudo apachectl graceful
httpd: Syntax error on line 117 of /usr/local/etc/apache2/2.2/httpd.conf: Cannot load /usr/local/opt/httpd22/libexec/apache2/libphp5.so into server: dlopen(/usr/local/opt/httpd22/libexec/apache2/libphp5.so, 10): image not found

以下是一些技术细节:

Mac操作系统版本:10.9.5

安装容量2.2:brew install -v httpd22 --with-brewed-openssl

安装PHP:brew install -v php54 --homebrew-apxs --with-apache

apache加载的模块:

$ sudo apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_dbm_module (shared)
 authn_anon_module (shared)
 authn_dbd_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_dbm_module (shared)
 authz_owner_module (shared)
 authz_default_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 cache_module (shared)
 dbd_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 ext_filter_module (shared)
 include_module (shared)
 filter_module (shared)
 substitute_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 log_forensic_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 expires_module (shared)
 headers_module (shared)
 ident_module (shared)
 usertrack_module (shared)
 unique_id_module (shared)
 setenvif_module (shared)
 version_module (shared)
 proxy_module (shared)
 proxy_connect_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_scgi_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 ssl_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 suexec_module (shared)
 cgi_module (shared)
 cgid_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 imagemap_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 php5_module (shared)
Syntax OK

Apache版本:

$ apachectl -v
Server version: Apache/2.2.29 (Unix)
Server built:   Feb 22 2015 18:17:03

如果有什么有用的,我可以提供更多信息(我很感激如何找到这些信息的说明,我的Mac apache foo不强大…)谢谢大家!

更新:

存在的文件路径:

  • /usr/local/opt/php54/libexec/apache2/libphp5.so

不存在的文件路径:

  • /usr/local/opt/httpd22/libexec/mod_php54.so
  • /usr/local/opt/httpd22/libexec/libphp5.so

对我来说,问题是在交换了一个版本后,我忘记了指向正确的路径:

完成后:

$ brew unlink php-71
$ brew reinstall php-56

它工作了一段时间,然后我犯了错误。

更改:

LoadModule php5_module /usr/local/Cellar/php56/5.6.26_3/libexec/apache2/libphp5.so
# TO
LoadModule php5_module/usr/local/opt/php56/libexec/apache2/libphp5.so

(用自己的版本替换)

重新启动apache为我解决了这个问题。