MacOS – Mac apache not working – apachectl configtest errors

apachemacos

I'm trying to get off of MAMP and run local versions of an AMP stack on my Mac, but when I try to start apache and run localhost from a browser, it's not coming up with anything.

In running apachectl configtest, I see the following errors, but I don't know how to fix.

Is there a way to do a clean reinstall of the AMP stack on a Mac? Is this even the recommended fix?

httpd: Syntax error on line 527 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+php-osx.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _unixd_config\n Referenced from: /usr/local/php5/libphp5.so\n Expected in: /usr/sbin/httpd\n in /usr/local/php5/libphp5.so

Best Answer

Looks like you have an extra conf file in the other directory. This file (+php-osx.conf) is trying to load PHP from /usr/local, rather than the system-supplied PHP. I know my PHP install works and am using the bog-standard Apple supplied Apache and PHP. Call to PHP module should be in the main httpd.conf file - this line is there, but commented out, by default in the Apple-supplied config:

LoadModule php5_module libexec/apache2/libphp5.so

And in other there should only be the single php5.conf file, contents:

<IfModule php5_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

The Apple-provided Apache2 should include the default config files in /etc/apache2, labeled with a suffix such as .original, .pre-update, or ~previous. Same goes for the conf files in subdirectories.