Search code examples
phpapacheosx-elcapitan

Installing PHP 5.6 on El Capitan: Syntax error with httpd.conf


While I am using MAMP Pro, I need to install Elasticsearch via OS X itself. However, I also need PHP 5.6 and El Capitan comes with 5.5 (I'm using OS X 10.11.6).

I followed a set of PHP installation instructions which resulted in an error:

httpd: Syntax error on line 119 of /private/etc/apache2/httpd.conf: Cannot load modules/mod_unixd.so into server: dlopen(/usr/modules/mod_unixd.so, 10): image not found

I did a bit of Googling, but failed to find anything definitive, and I'd prefer not to go making changes to httpd.conf until I have clue one.

I'm using Apache...

Server version: Apache/2.4.18 (Unix)
Server built:   Feb 20 2016 20:03:19
Server's Module Magic Number: 20120211:52
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)

Line 119 is:

LoadModule unixd_module modules/mod_unixd.so


Solution

  • The PHP installer had messed with the base httpd.conf file (commented out a ton of stuff) and added a new +php-osx.conf file in /etc/apache2/other/.

    The original config for httpd.conf seems to be backed up by default and kept at /etc/apache2/original/httpd.conf

    Moved the original httpd.conf to a backup location and rename the +php-osx.conf file so it isnt loaded:

    sudo mv /etc/apache2/httpd.conf /etc/apache2/httpd.conf.original
    sudo mv "/etc/apache2/other/+php-osx.conf" "/etc/apache2/+php-osx.conf.bak"
    

    Then copy the file from the folder /etc/apache2/original in as the default conf file:

    sudo cp /etc/apache2/original/httpd.conf /etc/apache2/httpd.conf
    

    This allowed sudo apachectl start to work and the webserver to be accessible.

    However php is still on 5.5 since the +php-osx.conf file has been disabled. To move forward here, the executable defined in that file needs to be used and the other php5.conf file disabled. But i currently think that this will not be enough to get php5.6 running