How to Create a WordPress Website Locally with Valet on Mac

Install Homebrew

Go to brew.sh copy the command and run it in your terminal

It will be something like this.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then update brew.

brew update

If the brew command is not found, you need to update Homebrew PATH.

export PATH="/opt/homebrew/bin:$PATH" >> ~/.zshrc

You should restart your environment.

source ~/.zshrc

Then try again to update brew.

Install PHP

brew install php

If you would like to install a specific version

brew install [email protected]

To make a specific PHP version as default:

brew link --overwrite --force [email protected]

Install composer (PHP Dependency Manager)

brew install composer

Update composer PATH.

export PATH="$PATH:$HOME/.composer/vendor/bin" >> ~/.zshrc

You should restart your environment.

source ~/.zshrc

Install MySQL with brew

brew install mysql

Once the installation is complete, start the MySQL server by running

brew services start mysql

Secure your MySQL installation, setup a root password by running

sudo mysql_secure_installation

Install WP-CLI with brew

brew install wp-cli

Check wp info.

wp --info

Install Valet with Composer

composer global require laravel/valet

Run valet install.

valet install

Run park command.

cd ~/Sites
valet park

Install WordPress

Create a directory “wordpress

cd ~/Sites
mkdir wordpress
cd wordpress

Download WordPress

wp core download

Set DbName, DbUser, and DbPass

wp core config --dbname=wordpress --dbuser=root --dbpass= --dbhost=localhost

Create Database as per above configuration.

wp db create

Set URL, Title, UserName, Pass, and Email.

wp core install --url=http://wordpress.test --title="WordPress Website" --admin_user=admin --admin_password=admin --admin_email=[email protected]

Check DB Tables.

wp db check

Create a Valet Link.

valet link

To set WP_DEBUG and WP_DEBUG_LOG to true for the Dev environment

wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw

Open the Site in the Browser.

valet open

Open code in VSCoce.

code .

To add SSL

valet secure

To remove SSL

valet unsecure

To rename your TLD from .test to something else, such as .dev

valet tld dev

Destroy the site

valet destroy


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *