Installation of PHP in Windows, MacOS and Linux

There are several steps for the installation of PHP in Windows MacOS and Linux. In this article we cover the most common installation procedure for each operating system. As a result, you can install and configure other tools and frameworks like Laravel.

Linux Installation


Using the default packages of Debian/Ubuntu repository.

sudo apt-get update
sudo apt-get install php

MacOS Installation

The default MacOS installation comes with PHP installed (Php 7.1 in High Sierra). However, it’s recommended to install and update Php 7 using HomeBrew, to get more extensions available without installing additional components:

brew install php@7.1

Or update if you have a previous version

brew upgrade php@7.1

Also, you need to replace symlinks to HomeBrew links:

brew link --overwrite --force php@7.1

As a result, you will be prompted to modify your ~/.bash_profile startup script. Run the commands in a console:

echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile

This new installation brings a bigger set of extensions already loaded (like php-intl). Now, your php.ini file will be located in /usr/local/etc/php/7.1/php.ini

Windows Installation

The most simple way to get a local PHP installation along with Apache HTTP server integration is using the XAMPP package installation. However, Setting up and configuring Nginx on Windows requires a bit more configuration. See the  Nginx documentation for additional setup help.

Looking for web hosting for PHP/Laravel projects?

MonsterMegs Web Hosting

See Also

Configure PHP and Laravel Framework

How to change the Laravel public folder path

Leave a Reply