Wednesday, 23 October 2013

Apache Config Files and Installing PHP extensions in OSX Mavericks

If you've just upgraded to Mavericks and found your local web stack doesn't work any more it's probably because all of your apache conf files have been moved during the upgrade.

The best option here is to copy the changes you made to the original conf files to the new ones. This goes for any conf files you had modified e.g. /etc/apache2/extra/httpd-vhosts.conf or httpd-ssl.conf.

You could just replace the new ones with the originals, but as I'm not sure if Apple have changed the versions of extensions etc it's probably safer just to copy the options over that you need.

You'll also see that Mavericks comes with an updated version of PHP.

php-config --version

If you were using the default installed version previously any additional extensions you had installed will need to be re-installed. For example I was missing the PhpRedis and igbinary extensions.

When I first tried to install the extensions I got the error message:

php.h not found

After doing some searching on this problem I found that Mavericks does not have the /usr/include folder anymore. There were a few sources suggesting creating a symbolic link to the include folder in the XCode Library folder (assuming Xcode was installed), but the actual solution that worked for me was to run the following command at the terminal:

xcode-select --install

More info on xcode-select can be found by typing "man xcode-select" in the terminal or on the Apple developer website - which I found on stackoverflow.

After running this command the two extensions installed without a problem. Job done!

Just in case this helps someone, here's the info on a stupid mistake I made; After running the above I was still having problems getting Redis to load, the follow error was thrown on Apache startup.

PHP Startup: redis: Unable to initialise module\nModule compiled with module API=20090626\nPHP compiled with module API=20100525\nThese options need to match\n in Unknown on line 0

I thought perhaps I'd used the previous version of phpize, but when I checked this was not the case:

phpize -v
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

Annoyingly this turned out to be my mistake. I re-downloaded the extensions, but neglected to notice my Downloads folder still contained the older versions from when I installed them the first time.

I'm assuming that if you run phpize on a directory for which it has already been ran, nothing will be changed because when I ran make && make install I installed the extensions compiled for the previous version of PHP.

Hopefully this helps someone waste less time than I just have....

No comments:

Post a Comment