Set Up a LAMP server on macOS

As macOS is built off of BSD, not Linux so you just need to setup Apache, MySql and PHP

Step 1 # Apache is already install on your Mac. This following command requires root to run so you’ll actually run it like this:

sudo apachectl <cmd>

To start server

sudo apachectl start

To stop server

sudo apachectl stop

To restart server

sudo apachectl restart

Step 2 # MySQL does not come installed on the macOS. so you’ll have to install it. You can easily install it useing homebrew. Run the following command to install MySql:

brew install mysql

Now get familiar with some basic MySQL commands:

To start

mysql.server start
To restart
mysql.server restart

To stop

mysql.server stop

Step 3# Installing PHP

Install PHP 7.3

curl -s | bash -s 7.3

Install PHP 7.2

curl -s | bash -s 7.2

Install PHP 7.1

curl -s | bash -s 7.1

Install PHP 5.6 – Running with OSX 10.11 El Capitan or lower versions.

curl -s | bash -s 5.6

Verify installation:

export PATH=/usr/local/php5/bin:$PATH  

and run the following command

php -v

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s