Problems with apache after update of php and mysql using homebrew

Solution 1:

OK, so I found the culprit.

It is amazing that no error message was visible in console or in the error logs, but I found a site which helped me a lot.

http://blog.joshdick.net/2012/07/28/troubleshooting_apache_in_os_x_10.8_mountain_lion.html

In that post, the author, Josh, suggested restarting apache using the following command:

sudo bash -x /usr/sbin/apachectl -k start

This command provides some error information, and overcomes the frustrating silent termination of Apache.

When I issued the command, it gave me the following output:

$ sudo bash -x /usr/sbin/apachectl -k start
+ ARGV='-k start'
+ HTTPD=/usr/sbin/httpd
+ test -f /usr/sbin/envvars
+ . /usr/sbin/envvars
++ DYLD_LIBRARY_PATH=/usr/lib:
++ export DYLD_LIBRARY_PATH
+ LYNX='lynx -dump'
+ STATUSURL=http://localhost:80/server-status
+ ULIMIT_MAX_FILES=
+ LAUNCHCTL=/bin/launchctl
+ LAUNCHD_JOB=/System/Library/LaunchDaemons/org.apache.httpd.plist
+ '[' x '!=' x ']'
+ ERROR=0
+ '[' 'x-k start' = x ']'
+ case $ARGV in
+ /usr/sbin/httpd -k start
httpd: Syntax error on line 118 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php54/5.4.11/libexec/apache2/libphp5.so into server: dlopen(/usr/local/Cellar/php54/5.4.11/libexec/apache2/libphp5.so, 10): Library not loaded: /usr/local/opt/zlib/lib/libz.so.1.2.7\n  Referenced from: /usr/local/Cellar/php54/5.4.11/libexec/apache2/libphp5.so\n  Reason: image not found
+ ERROR=1
+ exit 1

At the end of that snippet, you can see that it is trying and failing to load /usr/local/Cellar/php54/5.4.11/libexec/apache2/libphp5.so

Well, when I upgraded my homebrew installs, php5 was upgraded to 5.4.15, so that path was no longer valid. (Actually, the path was valid, since php was now at 5.4.15, and the path pointed to the older 5.4.11 lib, apache was terminating.

Modifying that line in https.conf solved the issue.