Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
This solved my problem exactly. Thank you. –  swt83 Apr 10 at 1:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.