Upgrade to PHP 7.1 or 7.2 on macOS

Sometimes you may get some issue when you upgrade php version from 5* to 7*.

I got this issue. When i check php version in terminal using “php -v”, it was showing PHP 7.1, but when i check through HTTP using , it shows me the older version (php 5*).

So, i have approached the below steps to upgrade PHP in apache server too, Since i have upgraded (unknowingly) my php version only in Cli version .

Download and Install PHP 7.0, 7.1 or 7.2

Open Terminal and run…

For 7.0 :

 curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0 

For 7.1 :

 curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 

For 7.2 :

 curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2 

After the successful installation, you will get the latest php version.

The version is filed in /usr/local/php5 – Test the php version by creating a php file named phpinfo.php in your web root with the single function:


So, the Main thing.

Apache Configuration : Actually you don’t need to do anything. Just FYI

For either PHP version install 7.2, 7.1 or 5.6 etc, the install script will also disable the previous PHP5.5 if it was enabled in the Apache configuration file /etc/apache2/httpd.conf . The new version is enabled in Apache right off the bat, the new install will comment out the older PHP module.

 #LoadModule php5_module libexec/apache2/libphp5.so 

It will load the new PHP version via the /etc/apache2/other/+php-osx.conf file.

So to reverse the behaviour uncomment the older PHP module in httpd.conf and remove the new config in other.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.