Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX Apache using wrong version of PHP

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

like image 728
Ben_hawk Avatar asked Nov 28 '12 19:11

Ben_hawk


People also ask

How do I change the default PHP version in Apache?

For PHP 8.0 to work correctly in the "PHP as Apache" mode, enable the PHP-FPM FastCGI option in the web server features: Settings → Features → Web-server (WWW) → Edit button. For FastCGI (Nginx + PHP-FPM) the version can be changed in PHP list at the user level or in the user editing from at the admin level.

Which version of PHP is my Apache using?

php in the Web server document root (installdir/apache2/htdocs/ for Apache or installdir/nginx/html for NGINX). Make sure the Web server is running, open a browser and type http://localhost/phptest.php. You should then see a screen showing detailed information about the PHP version you are using and installed modules.


1 Answers

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

like image 141
Bob Fanger Avatar answered Sep 22 '22 15:09

Bob Fanger