Install PHP

Table of Contents

Last Updated: April 2, 2021

In this tutorial we will show you how install PHP on Windows, MacOS and Ubuntu

Windows

  1. Go to https://windows.php.net/download/

  2. Download the latest stable ZIP version

    Output
    Figure 1. Download PHP Windows
  3. Extract the downloaded file to your preferred location e.g. C:/PHP

  4. Add the folder to system environment

  5. Inside any folder, right click on This PC then choose properties

    Output
    Figure 2. Add PHP to Windows environment variable
  6. Choose Advanced system settings

    Output
    Figure 3. Add PHP to Windows environment variable
  7. Click on Environment Variables…​

    Output
    Figure 4. Add PHP to Windows environment variable
  8. In the System variables section, select Path variable then press on edit

    Output
    Figure 5. Add PHP to Windows path variable
  9. You want to add your PHP extracted folder to the Path variable, so press on new and paste you folder location, then press ok

    Output
    Figure 6. Add PHP to Windows path variable
  10. To check if PHP was installed successfully, from the command line type

php -v

-s You should get the following

+

Output
Figure 7. Run PHP Windows

MacOS

By default MacOS ships with PHP, but you can replace it with any version you want in one line command.

Prerequisites

  • Homebrew

  • xcode developer tools

    1. Using the terminal use the following to upgrade to the latest version

brew install php

And you can use the following for a specific version

brew install [email protected]
  • You should find PHP config file in the following directory

/usr/local/etc/php/7.3/php.ini

Ubuntu

  1. Update the list of available packages then install the newer versions of the packages

    apt-get update && apt-get upgrade
  2. Install PHP

    apt-get install php
  3. Test if it is working

    php -v