3 min read

How to setup WordPress local on a Mac

Setup WordPress local on a M1 Mac with the terminal in just 5 steps. It's easy and works better than XAMPP or MAMP.

Last week, I decided that I wanted to build a WordPress theme again. WordPress moved to block themes and full site editing, and I wanted to know what that’s like. I never bothered setting up local WordPress development on my M1 Mac, and that was my first step.

On Intel Macs and Windows, I used tools like XAMPP and MAMP for local WordPress development. I never liked using them, so I looked at options with the terminal. I’m not a terminal hero, but it turned out to be easy. And, using it is much nicer than XAMPP or MAMP. Let’s have a look at how to do this.

Step 1: install Homebrew

First, we install Homebrew – a tool for installing packages. Open your terminal and copy and past the following:

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

Tap enter and the code runs. You might need to enter your Mac password. After running the installing you proceed to step 2.

Step 2: install PHP

There are multiple supported PHP versions. As of writing 8.1 is the latest and it’s supported by WordPress. That’s the version that I’m using for my local development.

Go back to the terminal and enter:

brew install php@8.1

This installs the PHP 8.1. If you want another version, just change the number.

You might (this is optional) want to change the maximum file size. In the terminal, type in:

cd /opt/homebrew/etc/php/8.1/
code php.ini

This opens the file in Visual Studio Code. If you use VIM, you change “code” in “VIM” or any other editor. You can also launch from finder. For finder:

  1. Open a finder window.
  2. Type “CMD + Shift + G”. This opens a prompt field.
  3. Past the path “/opt/homebrew/etc/php/8.1/“ and press return.
  4. Find php.ini and open it with Visual Studio Code.

In Visual Studio Code open Find and type upload_max_filesize. Change 2M to 10M or the size you prefer and save the changes.

php.ini file show max file size

Step 3: install MySQL

WordPress uses a MySQL database, and the next step is installing MySQL. We’re still using Homebrew for this, and in the terminal you type in:

brew install mysql

After running the MySQL installation, you start the service by typing:

brew services start mysql

You stop the service by replacing “start” with “stop” in the command.

Note: At this stage, I prefer opening new tabs in the terminal. One for general terminal use, one for MySQL and one for running PHP.

Now type the following in the MySQL tab:

mysql -u root

The terminal now opens the MySQL prompt that lets you interact with the service. For showing the installed databases, enter (don’t forget the semicolon at the end!):


It shows you something like this:

Terminal show MySQL databases

You can also create a new database, and that’s what we want to do. Use the following command:


You can name the database whatever you want. For deleting a database, use the command:

DROP DATABASE mywebsite;

When make a mistake, you can clear the command with “Ctrl + C”.

Step 4: download WordPress

You can download WordPress through the terminal, but manually is just as easy.

  1. Go to WordPress.org and download WordPress.
  2. Copy the download folder and paste it in the directory that you’re going to use. For example, Developer or Documents.
  3. Rename the pasted folder (e.g., mywebsite).

Step 5: setting up and launching WordPress

We’re now ready to launch WordPress. First we need to start the PHP server. In the terminal, go to – or open – the PHP tab.

We have to set the terminal to the directory where we pasted the WordPress files. In my example, that is Developer/mywebsite. Enter this command:

cd Developer/database

Now type:

php -S localhost:8000

This starts a server on your localhost on the port 8000. You can terminate the session with “Ctrl + C”.

Next, open your browser and navigate to localhost:8000. This will launch WordPress.

Language selection for WordPress setup

Select a language and click continue. On the next page you enter the database name, the user (root) and you clear the password field. The other fields are unchanged. Click submit and follow the instructions.

Fields for setting up WordPress

That’s it! You have now set up WordPress on your Mac and are ready to go.