Mac自制apache 2.2 php5_module分段故障

时间:2015-02-26 19:02:17

标签: php macos apache homebrew mod-php

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

我意识到我还没有在apache中启用Homebrew的apache php5_module,所以我补充道:

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 OS版本:10.9.5

安装apache2.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

1 个答案:

答案 0 :(得分:0)

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

完成后:

$ 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为我解决了这个问题。