【问题标题】:Mac homebrew apache 2.2 php5_module segmentation faultMac homebrew apache 2.2 php5_module 分段错误
【发布时间】:2015-04-29 07:31:48
【问题描述】:

我一直在将我的 apache 实现从 Mac 的内置 apache 转移到使用 homebrew 安装的 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 操作系统版本: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

【问题讨论】:

  • 您可能已经在这方面工作了一段时间,但我只是使用 Mamp 并继续工作。它开箱即用,让生活变得如此轻松。
  • 是的...我可能会谈到那个...在 Linux 发行版上这一直很顺利...
  • 在 Mac 上设置是一场噩梦。在我的 Debian 服务器上,什么都不是。在 Mac 上,您可以花上一整天的时间,但仍然无法正常工作。
  • 奇怪的是,我在使用 Macports 时从未遇到过问题,而且我从未从使用 Brew 的同事那里看到过这个问题。我的印象是自制软件会将模块添加到 conf 作为安装的一部分。你确定你没有 2 个 php 模块指令,这就是它的段错误吗?也许您只是缺少处理程序指令。
  • @prodigitalson:我在 Brew 中尝试这个主要是作为一个实验。我敢肯定,这只是混合我的 Brew/Mac 默认值/Linux 思维方式的问题……哈哈。但是不,没有重复。我会用更多的笔记更新帖子。

标签: php macos apache homebrew mod-php


【解决方案1】:

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

做完之后:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-28
    • 2023-03-05
    • 2018-06-06
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 2020-11-26
    • 2017-12-12
    相关资源
    最近更新 更多