How to Update PHP on Mac OS X fast and easy

Doing a PHP update can be a daunting task when you don’t know what you are doing. I created this post to help guys do just that. The Mac OS X comes with Apache and PHP pre-installed, but most of the time they are a couple of versions behind, meaning outdated.

  • Mac OS 10.11 (El Capitan) pre-installed with PHP 5.5
  • Mac OS 10.12 (Sierra) pre-installed with PHP 5.6
  • Mac OS 10.14 (Mojave) pre-installed with PHP 7.1

Most of the time I use Homebrew to update my Mac OS packages but I found a better option that makes it a lot easier. I found this package installer called PHP OSX for installing PHP version 5.3 to 7.3 so far. You can use this package if you have 10.6+ (Snow to Mojave systems). let me show you how you do it below.

Let’s install PHP version 7.2 in this case

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

Let’s configure Apache

If you are using the pre-installed (original – built-in) version of apache, PHP OSX will add a configuration file /etc/apache2/other/+php-osx.conf which will be loaded automatically by Apache.

Make sure you comment out this line below (this is the path to find this file below). Of course, you comment this out by removing the # symbols on that file 🙂

2. Do this sudo nano etc/apache2/httpd.conf

Comment out the line below

LoadModule php7_module /usr/local/php5/libphp7.so

On Older MAC OS X you might find the line below so comment it out if you find it.

LoadModule php5_module /usr/local/php5/libphp5.so.

After all of this, update your path.

3. Do this sudo nano ~/.bash_profile

Enter your computer password.

4. Copy and paste thisexport PATH=/usr/local/php5/bin:$PATH

And make sure you refresh that file.

5. source ~/.bash_profile

Or just close your terminal and reopen it.

Now confirm your PHP version.

6. php -v

That’s it guys I hope this helps a couple of you guys 🙂

2 comments On How to Update PHP on Mac OS X fast and easy

Leave a reply:

Your email address will not be published.

Site Footer