Local WordPress Setup in 5 Minutes using Valet for Mac users

Malisha Tharindu
3 min readMar 10, 2020

--

Hello Mac people,
This is brought you a solution for those who struggle to install Wordpress locally on Mac. Recently I got an Apple Mac Book pro to develop iOS apps due to my career aspects. So I had to move from Windows to Mac 🙄. In windows, I used Xamp or Wamp to create WordPress projects locally. But in Mac, I found this nice method to create Wordpress projects locally. Sharing is caring 😋.

First, what is Valet?
Valet is a Laravel development environment for Mac minimalists that doesn’t rely on Vagrant or Docker to load a separate operating system. So let's see how I did it…

Before you start, you have to make sure to obtain the following technical requirements.

Technical requirements 🛠

  • First thing, you are on a mac 💻 🖥
  • Git is installed
  • Homebrew is installed
  • Composer is installed
  • MySQL is installed- if you familiar with command line or you can use a GUI like MySQL Workbench or Sequel Pro

Now after full filling above requirements next thing is to install Valet.
So the following are the stages that have to do. 👇

stage 1: Install Valet

  1. update our brew install to make sure we have access to the latest repositories
$ brew update

2. PHP7.2 installed as Valet required

$ brew install php@7.2

3. Using Composer, install Valet

$ composer global require laravel/valet

You’re going to want to make sure that the valet command is globally accessible, so be sure to add ~/.composer/vendor/bin to your system’s “$PATH” by running export PATH=”$HOME/.composer/vendor/bin:$PATH”.

4. Testing valet command is globally accessible

$ valet

5. Install valet

$ valet install

So after run above command Valet is installed!
It means that your computer is ready to host PHP sites and frameworks locally. :smiley:

Stage 2: Create a Database

if you have installed MySQL and GUI like SequelPro to manage your databases, it is fine you can create a database named wordPress or whatever name you like.
or
If by chance you don’t have MySQL installed, run the following command. (Your username will become ‘root’ and the password will be empty ‘ ‘)

$ brew install mysql@5.7

log in to MySQL:

$ mysql -u root

if password as use -p parameter to provide the password for MySQL login

then create a new database named ‘Wordpress’ or another name,

mysql> create database wordpress;
mysql> quit;

So the database will create successfully.

Then all is ready to install Wordpress. Let’s do it.

Stage 3: Install WordPress

$ git clone https://github.com/WordPress/WordPress.git mysite
$ cd mysite

The above command will clone the most recent version of WordPress and copy the files to a new folder called ‘mysite’.

Instead of mysite there you can replace it with your project name.

Stage 4: Run Valet

$ valet link mysite

This command will handle all of the DNS routings and create a custom URL for us to access the site. Notice that the last parameter is the value of our local domain.

When you visit http://mysite.test, you’ll see the WordPress installation page. Just follow the instructions to complete the installation.

So these are the steps for setup WordPress locally on your mac.

If you want to set up more wp sites you have to skip some steps like valet install, MySQL install.

you can follow the below steps to set up another WordPress site.

1. Download WordPress into a new folder using the command line2. Run valet link and set up the URL to access the folder3. Install WordPress

Thank you and happy WordPressing 👋

--

--

Malisha Tharindu

Entrepreneur | iOS Developer | Web Developer with more than 5 Years of Experience. Founder of Learn with Malisha