简体   繁体   中英

Mac homebrew apache 2.2 php5_module segmentation fault

I've been moving my apache implementation from the Mac's builtin apache to apache installed with homebrew. This was going smoothly but when I went to test my PHP driven site it was clear that PHP wasn't running (apache itself worked and served the HTML, but the PHP was just sitting in the source in plain text).

I realized I hadn't enabled Homebrew's apache php5_module in apache yet so I added:

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

To my httpd.conf file. I restarted apache, and then things got REALLY interesting:

$ 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

After that my test site was gone entirely, commenting the php5_module line out brings back the HTML page, but obviously without working PHP. Does anyone have any sense of how this can happen, or how to fix it? I've seen some references to a mod_perl bug, but I don't have that enabled. (I also have no idea how the port issue could be connected to this.)

Also, changing the path to mod_php5 to be libexec/apache2/libphp5.so was equally ineffective.

$ 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

Here's some technical details:

Mac OS Version: 10.9.5

Installation apache2.2: brew install -v httpd22 --with-brewed-openssl

Installation of PHP: brew install -v php54 --homebrew-apxs --with-apache

Modules loaded by 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 version:

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

I can provide more information if there's something that would be helpful (I'd appreciate instructions on how to find that info, my Mac apache foo is not strong...) Thanks folks!

UPDATE:

File paths that exist:

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

File paths that don't exist:

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

For me the problem was after swapping a version I forgot to point to the right path:

After doing:

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

it worked for a while and then I got the error.

Changing:

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

(replace versions with your own)

And restarting apache fixed the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM