Table of Contents
Overview
I have been creating a Website Development Environment on my Mac, which is currently running macOS Catalina. 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 Catalina — 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:

One noticeable change in macOS Catalina 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 VPS). 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 Catalina 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 Catalina comes with fairly up-to-date versions of Apache and PHP 7.3.x, I describe how I used Homebrew to install and configure this software.
MySQL — I describe how I installed and configured MySQL in my Configure MySQL on macOS Catalina post. I specifically describe using MySQL 5.6.x because that’s the version that my Pair Networks VPS is using.
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.
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ brew install wp-cli $ wp --info OS: Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64 Shell: /bin/zsh PHP binary: /usr/local/Cellar/php@7.3/7.3.19/bin/php PHP version: 7.3.19 php.ini used: /usr/local/etc/php/7.3/php.ini WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /Users/george WP-CLI packages dir: WP-CLI global config: /Users/george/.wp-cli/config.yml WP-CLI project config: WP-CLI version: 2.4.0 |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$ brew install pwgen $ pwgen -s 20 1 H3k29ROINQnePjjIyDoB $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.6.47 Homebrew Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE wp509db; Query OK, 1 row affected (0.00 sec) mysql> CREATE USER 'gw509adm'@'localhost' IDENTIFIED BY 'H3k29ROINQnePjjIyDoB'; Query OK, 0 rows affected (0.01 sec) mysql> GRANT ALL ON wp509db.* TO 'gw509adm'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> \q Bye $ |
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:
1 2 3 4 5 6 7 8 9 |
$ cd ~/Sites/altoplace.tst $ ls -al total 0 drwxr-xr-x 2 george staff 64 Jun 27 11:07 . drwxr-xr-x 8 george staff 256 Jun 3 10:13 .. # Enter https://altoplace.tst in Safari and it should display # Index of / |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ pwd /Users/george/Sites/altoplace.tst $ wp core download Downloading WordPress 5.4.2 (en_US)... md5 hash verified: efcd1980afe80f873dd6b51ef622bf87 Success: WordPress downloaded. $ wp config create --dbhost=localhost --dbname=wp509db --dbuser=gw509adm --dbpass='H3k29ROINQnePjjIyDoB' --dbprefix=wp_ --dbcharset=utf8mb4 Success: Generated 'wp-config.php' file. $ pwgen -s 20 1 EaeAxeog7pf4gDLzZlSu $ wp core install --url=https://altoplace.tst --title="Altoplace" --admin_user=georgew509 --admin_password='EaeAxeog7pf4gDLzZlSu' --admin_email="george@altoplace.net" Success: WordPress installed successfully. $ |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Your new WordPress site has been successfully set up at: https://altoplace.tst You can log in to the administrator account with the following information: Username: georgew509 Password: The password you chose during installation. Log in here: https://altoplace.tst/wp-login.php We hope you enjoy your new site. Thanks! --The WordPress Team https://wordpress.org/ |
You can click on the Site URLs in the email to verify that your new WordPress install is working.
Conclusions
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.
Oh, just in case you were wondering, the example passwords are just examples and are not actually used by my https://altoplace.tst local site ?.