This guide forms part of my personal aide memoire, it’s hyper specific to my workflow and the tools I use.
Why use Valet
LocalWP is probably the first choice for most developers working on WordPress locally. Before this we had DesktopServer and manual options like XAMPP.
In some instances I prefer to use Valet, mainly because it’s faster, less bloated with GUI and gives me more control. Hence the need to install Valet.
Install Homebrew
Homebrew is the macOS package manager Valet relies on. Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
Then:
brew --version
Install PHP
Valet always uses the Homebrew-installed PHP and not the one bundled with macOS
brew install php
and verify the installation:
php -v
Install Composer
Composer is needed to install Valet.
brew install composer
and verify:
composer ---version
Don’t forget to install mysql
brew install mysql
Install Laravel Valet
Now the fun part: installing Valet globally via Composer.
composer global require laravel/valet
This installs Valet into Composer’s global bin directory, which is typically something like:
• ~/.config/composer/vendor/bin (newer systems)
To make sure you can run the valet command from anywhere in Terminal, you’ll need to add that directory to your shell’s PATH — which is a list of folders your terminal looks in when running commands.
When you type valet install, your terminal needs to know where the valet executable is. If it’s not in your PATH, you’ll get a “command not found” error.
Add Composer’s global bin to your PATH
It’s worth checking where your Composer global directory is, as this will alter the next step:
composer global config bin-dir --absolute
you are likely to see:
- /.config/composer/vendor/bin
or
- /.composer/vendor/bin
next run:
export PATH="$HOME/.composer/vendor/bin:$PATH"
(or /.config/composer/ )
Reload shell:
source ~/.zshrc
source ~/.bash_profile
Test that Valet is available
Valet --version
Now install Valet
You may need to enter your password at this point
valet install
This sets up:
- DnsMasq for .test domains
- Nginx for the web server
- starts PHP
Now to install WordPress on Valet
I choose to run a script inside my development folder. The script checks all the requried services are running and prompts for the basic WordPress details.
#!/bin/bash
# Ensure MySQL is running
# === MySQL Installation + Running Check ===
echo "🔍 Checking for MySQL installation..."
if ! brew list mysql &> /dev/null; then
echo "❌ MySQL is not installed."
read -p "Would you like to install MySQL now? (y/n): " INSTALL_MYSQL
if [[ "$INSTALL_MYSQL" =~ ^[Yy]$ ]]; then
brew install mysql
brew services start mysql
echo "✅ MySQL installed and started."
else
echo "⚠️ MySQL is required. Exiting."
exit 1
fi
else
echo "✅ MySQL is installed. Checking if it's running..."
if brew services list | grep mysql | grep started > /dev/null; then
echo "✅ MySQL is already running."
else
echo "🚀 Starting MySQL..."
brew services start mysql
fi
fi
# Ensure Valet is running
echo "Checking if Valet is running..."
valet status | grep 'Valet services are running' > /dev/null
if [ $? -ne 0 ]; then
echo "Starting Valet..."
valet start
else
echo "Valet is already running."
fi
# Prompt for site details
read -p "Enter site name (no spaces, e.g., mysite): " SITE_NAME
read -p "Enter WordPress admin username: " ADMIN_USER
read -p "Enter WordPress admin email: " ADMIN_EMAIL
# Prompt for admin password (silent input)
read -s -p "Enter WordPress admin password: " ADMIN_PASS
echo ""
read -s -p "Confirm WordPress admin password: " ADMIN_PASS_CONFIRM
echo ""
if [ "$ADMIN_PASS" != "$ADMIN_PASS_CONFIRM" ]; then
echo "❌ Passwords do not match. Exiting."
exit 1
fi
# Generate random database name and user
DB_SUFFIX=$(LC_ALL=C tr -dc a-z0-9 </dev/urandom | head -c 6)
DB_NAME="wp_${DB_SUFFIX}"
DB_USER="wp_${DB_SUFFIX}"
DB_PASS="password" # Set a default password if needed for non-root setups
# Create site folder
mkdir -p "$SITE_NAME"
cd "$SITE_NAME" || exit
# Download WordPress core
wp core download
# Create wp-config.php and database
wp config create --dbname="$DB_NAME" --dbuser="root" --dbpass=""
wp db create
# Install WordPress
wp core install --url="$SITE_NAME.test" --title="$SITE_NAME" --admin_user="$ADMIN_USER" --admin_password="$ADMIN_PASS" --admin_email="$ADMIN_EMAIL"
# Link with Valet
valet link "$SITE_NAME"
# Secure with HTTPS
valet secure "$SITE_NAME"
# Display summary
echo ""
echo "✅ Site created and secured with SSL!"
echo "🌐 URL: https://$SITE_NAME.test"
echo "🛢️ Database name: $DB_NAME"
echo "👤 Admin username: $ADMIN_USER"
echo "🔑 Admin password: (hidden - you set it)"
echo ""
Make it executable: chmod +x valetwp.sh
To run the script from within the same directory that it’s located in you can run:
./valetwp.sh
As an alternative you can specify the folder you’d like sites to be created in by changing the code above. Personally I prefer to keep the script in my dev folder and run it from there.