A method for upgrading to PHP 7.3 or 7.2 on macOS Mojave, Sierra or on OSX 10.6 – 10.11

macos
php
#1

The following instruction will guide you to upgrade to PHP 7.3 or 7.2 on macOS Mojave, Sierra or on OSX 10.6 – 10.11. You might wonder how to update your current PHP to the latest version due to the fact that PHP version 7.1 or earlier are not alive after December 2018. The recent macOS Mojave and High Sierra are already compatible with PHP7.1.

Download and Install PHP 7.3, 7.2, 7.1 or 7.0

Simply launch Terminal on your Mac and use the command line:

for 7.3

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3

or for 7.2

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

or for 7.1

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

or for 7.0

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

After that, there will be a warning error for if the later version of PHP is already installed. The version is stored in /usr/local/php5 – In order to check out the PHP version, generate a PHP file named phpinfo.php in your web root with the single function:

<?php phpinfo();?>

Browse to that file and see the version displayed.

In case you just want to just update your PHP to version 5.6, simply launch the Terminal and issue one command

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

Then use this command line to download and install PHP5.:

/usr/local/php5/

APACHE CONFIGURATION

In the case of installing PHP version install 7.3, 7.2, 7.1 or 5.6 etc, the install script will also deactive the previous PHP 5.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 installation will comment out the older PHP module.

#LoadModule php5_module libexec/apache2/libphp5.so

Then, it will load the new PHP version through the /etc/apache2/other/+php-osx.conf file.