Today I upgraded to Yosemite. Played with all the new cool shit. Then tried to get some work done, broken. Everything. Broken.
To explain a bit, Apache wasn’t loading so http://localhost wasn’t loading, let’s walk through the steps I took to fix this in case you’re seeing the same issue.
First we’ll need to reinstall PHP. Start by running brew update and brew doctor, fix what they recommend:
$ brew update $ brew doctor
Now for the reinstall, use whatever PHP version and flags you originally installed with. For this example we’ll be doing PHP 5.3 with MySQL and Postgres
$ brew reinstall php53 --with-mysql --with-pgsql --with-apache
At the end of the install process brew will tell you a few commands to run and give you the path to the PHP module. So let’s set PHP 5.3 to load at startup and load it right damn now
$ ln -sfv /usr/local/opt/php53/*.plist ~/Library/LaunchAgents $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
In the output we can see that the LoadModule line for the libphp5.so is
LoadModule php5_module /usr/local/opt/php53/libexec/apache2/libphp5.so
Go ahead and make a note of that LoadModule line.
If you’re using OSX Apache your httpd.conf has been backed up and a new one is now in place, this will show you all of the files:
$ ls /private/etc/apache2
You should see a httpd.conf and a httpd.conf.pre-update or something similar. The pre-update is your old config, you can find your old paths and any special configs/settings here. I’m assuming you already know the basics of setting up an Apache server.
Now we’re going to update the new httpd.conf with our particular settings, most of which you can grab from the .pre-update file.
Open /private/etc/apache2/httpd.conf in your editor of choice. Update the ServerRoot, DocumentRoot, and any Directory definitions as needed (1), you should be able to copy these from your httpd.conf.pre-update file.
Comment out any existing “LoadModule …. libphp5.so” lines.
At the bottom of the file add the LoadModule line from earlier (2)
LoadModule php5_module /usr/local/lib/libphp5.so
$ sudo apachectl -k restart
Hopefully everything will be good to go now. Watch the output from the apache restart for errors that will help you track down any additional issues.
(1) - My previous SystemRoot didn’t work, I had to use
(2) - I also had to add
AddType application/x-httpd-php .php