Update PHP 5.4.x using Homebrew? [closed]
I am trying to update PHP with Homebrew, but Apache isn’t loading the correct version. I have run brew upgrade and have downloaded PHP 5.4.29. However, when I look up what version of php I am running, it still says 5.4.24. Is there an extra step that I am missing?
I am running the following environment:
OS X 10.9.3
There are a few things you may need to look at to ensure the right version of PHP is being used.
brew link FORMULA
Homebrew maintains all of its various versions of packages in the
/usr/local/Cellar directory. However, you should not directly link to files in the Cellar directory; rather, you should make use of
brew link, which creates symlinks in
To link a formula, just use
brew link FORMULA, but if the formula is already linked, you may need to unlink and relink it to ensure the links refer to the latest version:
$ brew unlink FORMULA && brew link FORMULA
Ensure you’re loading the right version of mod_php
If you’re using the Apple-provided Apache (or if for whatever reason you weren’t but were using a non-Homebrew PHP), you need to ensure you’re loading the correct module library.
You will need to add the following line to your httpd.conf file:
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
Once you’ve ensured the correct version of PHP is loaded, make sure you restart Apache before testing that the correct version is running. Simply run the following command to restart the Apache daemon:
$ sudo apachectl -k restart