How to install WordPress on macOS


Note: This post has been updated for macOS Big Sur.

I have been creating a Website Development Environment on my Mac, which is currently running macOS Big Sur. I have added a MAMP (LAMP when running on Linux) stack to support various website development tools, such as WordPress. A MAMP stack is based on the macOS operating system, the Apache 2 web server, the MySQL database management system, and the PHP scripting language. You can easily install a MAMP stack by installing a MAMP App as described by the WordPress Codex, Installing WordPress Locally on Your Mac with MAMP. However, I chose to manually install my MAMP stack because I wanted to learn more about the technology.

Installing the MAMP Stack

I have written several posts that detail installing all of the components of my MAMP stack. Here, I will describe the components and what they do.

macOS Big Sur — Of course, this is the operating system that I am using. Under the hood, it is very Unix-like, so if you are familiar with Linux (or other Unix-like OSs), you should be able to follow along. You need to be familiar and comfortable with using the Terminal and command line:

macOS terminal window running “Oh My Zsh”

One noticeable change in macOS from earlier macOS releases is that the Terminal has switched from the bash shell to zsh as the default shell command environment. At first, I resisted this change, but I have since adopted zsh on my Mac (I still use bash on my Pair Networks shared host). Out of the box, zsh is a bit raw, so I installed the Oh My Zsh framework to enhance my zsh experience. Oh, I also want to note that bash scripts mostly work with zsh. I have occasionally had to tweak them to work.

Apache and PHP — I talk about setting up both of these in my Configure Apache and PHP-FPM on macOS post because that’s what you need for creating websites that don’t require the use of a full-fledge database management system. I also describe using Dnsmasq to support named virtual hosts on your local machine. And I describe how to set up SSL (TLS) to test SSL enabled virtual hosts. While macOS comes with fairly up-to-date versions of Apache and PHP, I describe how I used Homebrew to install and configure this software. Actually, the next version of macOS, after Big Sur, will not even include PHP:

MySQL — I describe how I installed and configured MySQL in my Configure MySQL on macOS post. I specifically describe using MySQL 5.7.x because that’s the version that I am using on my Pair Networks shared host.

Send-Only SMTP Server — This is not part of the MAMP stack, but I include it because you will need it when you want to test web server Apps that generate email, such as a WordPress contact form. WordPress generates an email message after a successful installation. Mail servers can be very complicated to set up, however, we really only need to send system-generated email. We don’t need a full-fledge mail server. I wrote a post about how to Create a Send-Only SMTP Server on macOS Using Gmail. With this setup, we are routing system-generated email out of our Mac and sending it to a Gmail SMTP server that relays the email for us. It is very simple to set up on a Mac. This is a free service for low-volume email. Perfect for our development environment.

With the above software installed (or your own MAMP/Web Server stack), we are ready to install WordPress. I am going to describe installing WordPress via the Command Line. Or more specifically, I am going to use the command line interface for WordPress, WP-CLI. This is a very handy tool to use for working with WordPress from the command line. You can do a lot more than just install WordPress.

Installing WordPress using WP-CLI

The first step is to install WP-CLI if it’s not already installed. This can be easily done with Homebrew:

As shown, the WP-CLI functions are executed via the wp command. Use wp help to see a list of subcommands.

Create the WordPress Database

I am using MySQL to create a WordPress database. We also need to create the database user and grant permissions for the user to access the database. Here’s an example, which also shows how to use pwgen to generate a user password for the database:

Verify Your Virtual Host

Before you continue with installing WordPress, you need to verify that you have set up a working Virtual Host. For example, all of my Virtual Hosts live under my ~/Sites directory. I am going to install WordPress for my https://altoplace.tst Virtual Host.

Install WordPress using the WP-CLI download, config create, and Install Commands

If you have created your database and verified that your Virtual Host is working, we are ready to install WordPress using three WP-CLI commands to download WordPress, create our WordPress user configuration, and then do the install. Here is an example:

After downloading WordPress, the wp config create command uses the database and user credentials that we just created. Before executing the install command, I generated a password for the WordPress admin user that is created by the install command. If all went well, the core install reports Success. Also, if you previously created a send-only SMTP server per my post that I referenced earlier, you should receive an email from your WordPress site that you just installed:

You can click on the Site URLs in the email to verify that your new WordPress install is working.


Assuming that you had a working MAMP stack with at least one SSL-enabled virtual host and followed my WordPress install description, you should have a complete working WordPress installation on your Mac.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.