OSX Apache using wrong version of PHP

22,255

Solution 1

Did you follow all the instructions provided in the Caveats?

Run brew info php54 to see them again.

Especially the line:

To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/Cellar/php54/5.4.8/libexec/apache2/libphp5.so

Solution 2

Apache is not aware of the homebrew version of PHP (i.e. /usr/bin/php). You see it on the command line because you've likely modified your PATH (i.e. /usr/local/bin/php).

You can modify this in your httpd.conf file.

I am not a fan of homebrew or other package libraries. Primarily because Mac OS X is built atop Unix. Furthermore, all but MySQL are installed natively. Here's an article on installing Apache, MySQL, and PHP on Mac OS X.

Disclaimer: I wrote that article.

Share:
22,255
Ben_hawk
Author by

Ben_hawk

My names Ben, and Im a student at the University of Plymouth, studying for a degree in Web Applications Development. This is all!

Updated on January 20, 2021

Comments

  • Ben_hawk
    Ben_hawk over 3 years

    I followed a guide which used home-brew to install the lastest version of php (5.4.8) on OSX Mountain Lion.

    I then followed a guide which showed me how to setup and use the pre-installed apache on OSX.

    However when I try running up a base Symfony 2 project I get a bunch of errors relating to missing date.timezone in the php.ini.

    However I have this correctly setup the php.ini but doing a quick phpinfo() in the Symfony project shows that its using the old preinstalled version of php (5.3) rather than the new one.

    In terminal if I type which php & php -v, It shows the correct new version is being used.

    enter image description here

    But the phpinfo() shows

    enter image description here

    enter image description here