Javatpoint Logo
Javatpoint Logo

How to Install PHP on macOS

Introduction

PHP is a server-side scripting language. Originally it was designed for web development but it can also be used as a general-purpose language. It was created by Rasmus Lerdorf in 1994. Originally it stood for Personal home page but now It stands for Hyper Text Preprocessor. PHP code can be embedded into HTML. PHP is basically an interpreted language implemented by a web server or CGI executable. In this tutorial, we will learn the steps to install PHP on macOS.

Prerequisites

  1. MacOS
  2. Login as an administrator on terminal
  3. Homebrew package installer must be configured on the system.

Installation

1) Installation of PHP includes following steps.

Update the local repository index of Homebrew package installer

Following command can be used to update the local repository index of homebrew package installer.

2) Install PHP

The latest version of PHP is PHP 7.1. it can be easily installed with a single command as follows.

In case, no similar formulae found, we need to tap into the other PHP repositories by running the following command.

How to Install Php in Macos
How to Install Php in Macos1

PHP 7.1 is installed inside /usr/local/Cellar. In order to execute php globally, we need to set path in .bash_profile stored in the user's home directory. Open the file using VI editor and add the following line.

Verify PHP

To verify correct version of PHP is installed on our system, we can execute the following command.

How to Install Php in Macos2

Hence, we have successfully installed and get started with PHP version 7.1.12.






Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA