1

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
lostphilosopher
  • 4,361
  • 4
  • 28
  • 39
  • You've probably been working on this for awhile, but I just use Mamp and get on with things. It works out of the box and makes life so much easier. – Halfstop Feb 26 '15 at 19:09
  • Yeah... I might be coming to that... This has always gone so smoothy on Linux distros... – lostphilosopher Feb 26 '15 at 19:16
  • It's a nightmare on Mac to setup. On my Debian servers, it's nothing. On a Mac, you can spend all day and still not have it working. – Halfstop Feb 26 '15 at 19:19
  • Odd ive never had an issue using Macports, And ive never seen this issue from colleagues using Brew. I was under the impression homebrew would add the module to the conf as part of the install. Are you sure tou didnt have 2 php module directives and thats whay it was segfaulting? Perhaps you were jsut missing the handler directives instead. – prodigitalson Feb 26 '15 at 19:21
  • @prodigitalson: I'm trying this out with Brew largely as an experiment. I'm sure it's just a matter of mixing my Brew/Mac defaults/Linux mindset... Haha. But no, there's no duplicate. I'll update the post with some more notes. – lostphilosopher Feb 26 '15 at 19:29
  • @Halfstop: I'm glad I'm not the only person to have trouble with this! – lostphilosopher Feb 26 '15 at 19:29
  • When you stop apache, I'd do a `ps aux |grep 'httpd'` just to be extra sure they're not running. `sudo dtruss -f apachectl start` will spit out a bunch of terrifying looking stuff, but if you scroll all the way back up to where the output started and just glance over the output, you can see where something tried to read/load, more often than not the error is helpful or obvious enough to point you in the right direction. I've always just compiled php from source, using the default apache install on OSX. I'm happy to share the `./configure... ` if you're interested. It really isn't hard at all. – Patrick Webster Feb 26 '15 at 22:36
  • Wait a minute.... shouldnt you be loading the httpd.conf from `HOMEBREW_PREFIX/etc/apache2/2.2/httpd.conf` Are you sure the correct version of httpd is running? – prodigitalson Feb 26 '15 at 22:58

1 Answers1

0

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.

RVandersteen
  • 2,067
  • 2
  • 25
  • 46