How to Install PHP on Mac OS

How to Install PHP on Mac OS

If you’re a Mac user and want to start coding in PHP, you’ll need to install PHP on your machine first. In this tutorial, We will show you how to properly install and configure PHP with mac OS system.

Once you have PHP installed, you can customize its configuration settings and install extensions to enhance its functionality. You can also start a PHP server on your local machine to test your web applications.

How to Install PHP on Mac OS using Brew

Installing PHP in Mac OS is a very easy and common task. Follow these steps and install PHP on your Mac today.

  • Step 1: Install Homebrew
  • Step 2: Install PHP
  • Step 3: Verify PHP Installation
  • Step 4: Configure PHP
  • Step 5: Install PHP Extensions
  • Step 6: Start PHP Server

Step 1: Install Homebrew

Homebrew is a package manager for macOS that simplifies the installation of software. To install Homebrew, open the Terminal app on your Mac and enter the following command:

/bin/bash -c "$(curl -fsSL"

Follow the instructions on the screen to complete the installation process.

Step 2: Install PHP

When you run the command on the terminal, the command installs PHP on your system. Now, you need to run the following command to install PHP:

brew install php

This will download and install the latest version of PHP available in Homebrew’s repository. Depending on your internet speed and Mac configuration, this may take a few minutes.

Step 3: Verify PHP Installation

Now, you need to verify installed PHP version, So open terminal app and run the following command:

php -v

It shows the PHP-installed version.

Step 4: Configure PHP

Enter the following command in the Terminal app:

php --ini

This will display the location of the php.ini file on your machine. Open the file in a text editor and modify the settings as needed. Some common configuration changes include increasing the maximum execution time and memory limit.

Step 5: Install PHP Extensions

PHP is easy to install with the help of Homebrew. It is equally easy to install a PHP extension.

To install a PHP extension, enter the following command in the Terminal app:

brew install php-extension-name

Replace “extension-name” with the name of the extension you want to install. For example, to install the MySQL extension, enter the following command:

brew install php-mysql

Step 6: Start PHP Server

To start a PHP server on your Mac, navigate to the directory containing your PHP files in the Terminal app and enter the following command:

php -S localhost:8000

Now, open the browser and visit http://localhost:8000 in your web browser.


Installing PHP on macOS is a straightforward process thanks to Homebrew. With PHP installed, you can start coding your web applications using one of the most popular server-side scripting languages available.

Recommended Tutorials

  1. Autocomplete Search Box in PHP MySQL
  2. Compare Arrays PHP | PHP array_diff() Function
  3. Get, Write, Read, Load, JSON File from Url PHP
  4. Functions: Remove First Character From String PHP
  5. Remove Specific/Special Characters From String In PHP
  6. How to Replace First and Last Character From String PHP
  7. Reverse String in PHP
  8. Array Push, POP PHP | PHP Array Tutorial
  9. PHP Search Multidimensional Array By key, value, and return key
  10. json_encode()- Convert Array To JSON | Object To JSON PHP
  11. PHP remove duplicates from multidimensional array
  12. PHP Remove Duplicate Elements or Values from Array PHP
  13. Get Highest Value in Multidimensional Array PHP
  14. PHP Get Min or Minimum Value in Array
  15. String PHP to Uppercase, Lowercase & First Letter Uppercase
  16. PHP: isset() vs empty() vs is_null()
  17. Chunk_split PHP Function Example
  18. PHP Function: Date and Time With Examples
  19. Reverse Number in PHP | PHP Tutorial


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

One reply to How to Install PHP on Mac OS

  1. If you are using macOS, there’s a new option you can try: It includes all versions of PHP, MariaDB, and PostgreSQL, as well as Redis and Memcached. You can run multiple versions of PHP instances at the same time and it’s easy to switch between them for debugging/testing. With just a few clicks, you can enjoy your PHP development environment.

Leave a Reply

Your email address will not be published. Required fields are marked *