I am hoping someone here can assist me.

I upgraded php and related files using brew upgrade on my mac which is running Mac OS X 10.8.3. Everything was working fine before and I just wanted to update.

After I ensured that everything was fine as regards config files and vhosts I issued the following command to restart apache:

sudo apachectl restart

I then tried to connect to http://localhost/phpinfo.php

Safari errored out with:

Safari can’t open the page “http://localhost/phpinfo.php” because Safari can’t connect to the server “localhost”.

in the terminal, issuing the following command:

apachectl -V | grep httpd.conf

results in:

-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

Server root is:

ServerRoot "/usr"

and Document Root is:

DocumentRoot "/Volumes/sites"

DocumentRoot has permissions set to 755

As I said, everything was working fine until I restarted apache.

Now, nothing works.

I am completely lost, and I need to get things working again.

1 Answer 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.


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:
+ LYNX='lynx -dump'
+ STATUSURL=http://localhost:80/server-status
+ LAUNCHCTL=/bin/launchctl
+ LAUNCHD_JOB=/System/Library/LaunchDaemons/org.apache.httpd.plist
+ '[' x '!=' x ']'
+ '[' '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
+ 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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .