我一直在将我的 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
阿帕奇版本:
$ 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