I recently purchased brand new MacBook Pro and I had to install NGINX, PHP and MySQL in my MacBook Pro. In this article, I am going to share my experience for how to install NGINX, PHP and MySQL on your Mac. This article is for someone interesting to set-up web development environment, especially for the first time.

  1. Mysql Workbench For Mac Mojave
  2. Mysql For Mac Os Mojave
  3. Mysql For Mac Mojave Ca
  4. Mysql Install Mac Mojave
  5. Mysql For Mac Mojave Download

Reson I choose Nginx over Apache web server is its light-weight resource utilization and its ability to scale easily. Also, Niginx has grown its popularity during last few years. Furthermore, Nginx is often selected by administrators for its resource efficiency and responsiveness under the heavy load.

My MacBook Pro installed Mac OS High Sierra and it was shipped with pre-installed PHP package. So, depending on your web development environment setup, you may need to upgrade default PHP version to the latest version.

Aug 17, 2019  After I type 'sudo nano /usr/local/mysql/my.cnf' in terminal, it asks for my computer user login password, and then it returns with a blank, empty white terminal which says new file. Mac OS Mojave. August 17, 2019 12:24AM Re: Can't start/connect to localhost server, Mac OS Mojave. Peter Brawley. Type y and press enter and you'll see that Rails has updated the following files: force config/database.yml gsub Gemfile gsub Gemfile. This adds the mysql gem to the Gemfile. Before installing it, open up the Gemfile, look for the line that starts with gem mysql, and check which version of the gem it's using.

Normally, Mac OS X doesn’t ship with its own copy of MySQL. So, you will have to install MySQL on your local machine.

Also, remember this article only explain to install these required packages on your local machine. Alternatively, you can set up similar development environment by using Docker or Vagrant. I will write another post in this regarding.

Now let’s have a look how to install NGINX, PHP and MySQL on Mac OS local environment.

Install NGINX

I prefer to use Homebrew package manager to install required additional packages on my Mac OS X.

If you haven’t install Homebrew on your Mac, you just need to copy paste following command on your terminal and Homebrew will install on your Mac automatically. Remember you need an Internet connection to download these packages.

Once you installed Homebrew, you can install NGINX by using the following command.

Nginx will set following document root by default. But you can change to any path using nginx.conf file.

NGINX default document root

/usr/local/var/www

Configure NGINX virtual hosts

I have included my pre-configured virtual hosts as a zip file.

So you can download my pre-configured NGINX virtual host files here.

Once you download the zip file, unzip the contents and then you just need to copy into the following path. Furthermore, my NGINX virtual hosts specially configured for developing Magento 1, Magento 2 and WordPress projects in my local.

Step 1 – Rename existing “nginx” folder /usr/local/etc/

Step 2 – Copy downloaded “nginx” folder in to /usr/local/etc/

Step 3 – Change your system username

All the pre-configured NGINX virtual hosts are located under the following path.

/usr/local/etc/nginx/servers

You will find four configuration files under the above path.

  1. 00_upstream.conf – For Fast CGI upstream
  2. 10_localhost.com.conf – For Magento 1 hosts
  3. 20_localhost.com.conf – For Magento 2 hosts
  4. magestyle.conf – For WordPress and general hosts

Also, you will notice, each virtual host’s document root is defined under the above configuration files.

Update your host file

Also, you will need to update your host file for the custom virtual host names. So you can have a look my host file as an example.

NGINX server state management

Start NGINX Server

Reload NGINX Server

Stop NGINX Server

Test and verify NGINX services

My local configuration examples:

For Magento 1 projects

Local Document Root – /Users/chatura/htdocs/m1-local

Host name – http://m1-local.localhost.com/

Configuration file path – /usr/local/etc/nginx/servers/10_localhost.com.conf

For Magento2 projects

Local Document Root – /Users/chatura/htdocs/m2-local/web

Mysql For Mac Mojave

Host name – http://m2-local.m2.localhost.com/

Configuration file path – /usr/local/etc/nginx/servers/20_localhost.com.conf

For WordPress and other projects

Local Document Root -/Users/chatura/htdocs/wp-test

Mysql For Mac Mojave

Host name – http://wp-test.localhost.com/

Local Document Root – /usr/local/etc/nginx/servers/magestyle.conf

Install PHP

If you follow the following steps, you can replace default PHP with Homebrew PHP version. Also, you can easily upgrade or switch your PHP version according your project requirement.

Especially I am going use my development setup for Magento 2 development. So I followed the Magento technology stack documentation before decide which PHP version I need to install. So I am going to install PHP 7.1 version in my local environment as per the Magento 2 latest technology stack.

Use following “brew tap” command to allow Homebrew to tap into Homebrew PHP to formulae. Once you’ve done this, you’ve expanded your options of installable PHP versions. So these additional Git repos will be saved inside the (usr/local/Library/Taps) directory,

To check list of available configuration options

Install PHP without Apache and with PHP FPM

Install additonal PHP extensions

Setup PHP CLI binary

In addition, if you want to use the PHP command line tools, you need to update the $PATH environment variable of your shell profile.

If you use the default Bash shell:

If you use ZSH:

If you are not sure which one you use, run following code in your terminal. I am using ZSH and it returns “/bin/zsh”

Mysql Workbench For Mac Mojave

Configure PHP using PHP-FPM

PHP-FPM is a modern way of running PHP with a process manager and the FastCGI protocol. Also, this enables high performance as well as easy switching between various versions of PHP.

Note: Also you can install many PHP version with Homebrew package manager. You just need to link required PHP version and unlink other PHP versions.

Check Installed PHP version and php.ini file

PHP service management

Install MySQL

Mysql For Mac Os Mojave

Let’s install MySQL server.

Mysql For Mac Mojave Ca

Also, you can use the following command to MySQL server gets automatically started and stopped when the Mac is shutdown/powered on.

Mysql server for mac

So, you can start MySQL start service manually using the following command for now.

MySQL service management

Test MySQL connection

I hope this article will help you to install Nginx, PHP, MySQL on your Mac OS. Let me know in case you’re stuck at some point or have general feedback. Please feel free to comment below.

I am more of a command line user when accessing MySQL, but MySQLWorkBench is by far a great tool. However, I am not a fan of installing a database on my local machine and prefer to use an old computer on my network to handle that. If you have an old Mac or PC, wipe it and install Linux Server command line only software on it. Machines as old as 10/15 years and older can support Linux easily. You don't even need that much RAM either but I'd got with minimum of 4GB for MySQL.


Or...


Use Virtualbox by Oracle to create a virtual server on your local machine. I recommend Centos 7 or Ubuntu 18.04. The latter I used to use exclusively but it has too many updates every other week, whereas Centos 7 updates less often and is as secure regardless. But you will need to learn about firewalls, and securing SSH because SSH is how you will access the virtual machine for maintenance. You will have to learn how to add/delete users, how to use sudo so you can perform root based commands etc. There is a lot more to the picture than meets the eye when you want to use a database.


I strongly recommend not installing MySQL on your local machine but use a Virtual Machine or an old machine that you can connect to on your local area network. It will give you a better understanding of security when you have to deal with a firewall and it is always a good practice to never have a database on the same server/computer as your project. Databases are for the backend where access is secure and severely limited to just one machine via ssh-keys or machine id. If you don't have the key or ID you ain't getting access to the DB.

Mysql Install Mac Mojave


There are plenty of tutorials online that will show you how to do this. If you have the passion to learn it will come easy.

Mysql For Mac Mojave Download

Posted on