How to upgrade to php 7.4, 7.3, 7.2,... on MacOS?

How to upgrade to php 7.4, 7.3, 7.2,... on MacOS?


In this share, I will quickly show you instruction to upgrade current php on MacOS Mojave, High Sierra, Sierra,… to newer versions: 7.4, 7.3, 7.2,…

How to check current php version on your MacOS?

  • Open Terminal (Found under /Application/others/)
  • Enter the following command line:
php -v

Similarly, you will find:

  • php 7.1 on High Sierra
  • php 5.6 on Sierra
  • php 5.5.x on El Capitan

Whatever your php version is, if you want to upgrade to newer version, ENTER one of the following command lines:

  • Upgrade to php 7.4
curl -s | bash -s force 7.4
  • Upgrade to php 7.3
curl -s | bash -s force 7.3
  • Upgrade to php 7.2
curl -s | bash -s force 7.2
  • Upgrade to php 7.1
curl -s | bash -s force 7.1
  • Upgrade to php 7.0
curl -s | bash -s force 7.0
  • Someone may just ưant Upgrade to the latest of php 5.6
curl -s | bash -s force 5.6

Apache Configuration

If you upgrade to 7.4, 7.3, 7.2, 7.1 or even the latest of 5.6, 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/

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

So to reverse the behavior uncomment the older PHP module in httpd.conf and remove the new config in other .
Please leave a comment for your contributions.