Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 

Repository files navigation

newwp.sh

A zero-friction WordPress site bootstrapper for local development with Laravel Herd.

Spin up a fully-configured, secured, plugin-loaded WordPress site at https://<sitename>.test with a single command.

newwp mycoolsite

Table of Contents


What It Does

In a single command, newwp will:

  1. βœ… Create a new site directory under ~/Herd/
  2. βœ… Download the latest WordPress core
  3. βœ… Create a fresh MySQL database
  4. βœ… Generate wp-config.php with fresh salts, debug enabled, and revision limits
  5. βœ… Install WordPress with your admin account
  6. βœ… Wipe default content (Hello World post, sample page, etc.)
  7. βœ… Remove bundled plugins (Hello Dolly, Akismet) and inactive themes
  8. βœ… Set timezone, disable comments/pingbacks, enable pretty permalinks
  9. βœ… Secure the site with HTTPS via Herd
  10. βœ… Install + activate every plugin you keep in ~/Scripts/zips/
  11. βœ… Open the login page in your browser

Total time: ~10 seconds.


Requirements

Tool Purpose Install
Bash 4+ Script runtime Pre-installed on macOS
Herd Local PHP/MySQL/Nginx herd.laravel.com
WP-CLI WordPress command-line interface brew install wp-cli
MySQL Database server Bundled with Herd Pro, or brew install mysql
unzip Plugin zip extraction Pre-installed on macOS

Installation

1. Clone or place the script

Drop newwp.sh into ~/Scripts/ (or wherever you keep your shell scripts).

chmod +x ~/Scripts/newwp.sh

2. Create the credentials file

The script reads database and admin credentials from ~/.config/newwp.env β€” never commit this file to git.

mkdir -p ~/.config
touch ~/.config/newwp.env
chmod 600 ~/.config/newwp.env

Open it in your editor and add:

# Database credentials (your local MySQL user)
DB_USER=root
DB_PASS=your_mysql_password

# WordPress admin account (used for every new site)
WP_ADMIN_USER=yourname
WP_ADMIN_EMAIL=you@example.com
WP_ADMIN_PASS=a_strong_password_here

πŸ’‘ The chmod 600 step locks the file to read/write for you only β€” important since it contains plaintext passwords.

3. Create the plugin zips folder

mkdir -p ~/Scripts/zips

Drop any premium or pre-configured plugin .zip files in here. Every new site will get them auto-installed and activated. Leave the folder empty if you don't need this.

4. Add a shell alias (optional but recommended)

Add this to your ~/.zshrc:

alias newwp="~/Scripts/newwp.sh"

Then reload:

source ~/.zshrc

Configuration

All tunable values live in ~/.config/newwp.env:

Variable Description Example
DB_USER MySQL username root
DB_PASS MySQL password secret123
WP_ADMIN_USER WordPress admin login username
WP_ADMIN_EMAIL WordPress admin email you@example.com
WP_ADMIN_PASS WordPress admin password super_secure_pw

Other settings (timezone, permalink structure, debug flags) are hardcoded in the script β€” see Customizing the Defaults.


Usage

Create a new site

newwp mysite

This creates:

  • A folder at ~/Herd/mysite/
  • A database named wp_mysite
  • A site reachable at https://mysite.test

Common patterns

# Client project
newwp acme-redesign

# Quick test
newwp test-$(date +%Y%m%d)

# Plugin development sandbox
newwp gravityforms-test

What Happens Under the Hood

The script runs through these phases β€” each one prints a colored status header:

==> Setting up site directory
  βœ“ Created ~/Herd/mysite

==> Downloading WordPress
  βœ“ WordPress core downloaded

==> Configuring database
  βœ“ Database wp_mysite created

==> Tuning wp-config.php
  βœ“ Fresh salts + debug + revision limit set

==> Installing WordPress
  βœ“ WordPress installed

==> Cleaning default content
  βœ“ Removed default plugins
  βœ“ Removed inactive themes

==> Setting site preferences
  βœ“ Timezone, comments, and permalinks configured

==> Securing site with HTTPS
  βœ“ HTTPS enabled via Herd

==> Installing custom plugins
  βœ“ Custom plugins extracted
  βœ“ All plugins updated and activated

βœ“ Site ready: https://mysite.test

Customizing the Defaults

Open ~/Scripts/newwp.sh and look for the "Tuning wp-config.php" and "Setting site preferences" sections.

Current defaults

Setting Value
Timezone America/Boise
Comments Closed by default
Pingbacks Closed by default
Permalink structure /%postname%/
WP_DEBUG true
WP_DEBUG_LOG true
WP_POST_REVISIONS 5
Salts Freshly randomized

To change

Just edit the relevant wp option update or wp config set line. For example, to change the timezone:

wp option update timezone_string "America/New_York"

Optional Additions

Here are useful WP-CLI commands you could fold in to extend the script:

Default Pages

Scaffold the standard pages every site needs:

wp post create --post_type=page --post_title='About'   --post_status=publish
wp post create --post_type=page --post_title='Contact' --post_status=publish
wp post create --post_type=page --post_title='Privacy' --post_status=publish

Auto-Install Plugins from WP.org

Skip the zip dance entirely for any plugin on the WordPress.org repository:

wp plugin install advanced-custom-fields wordpress-seo wp-mail-smtp --activate

Set a Default Theme

wp theme install astra --activate

Generate Test Content

For development sites where you want some posts to play with:

wp post generate --count=20
wp comment generate --count=50

Build a Navigation Menu

wp menu create "Main Menu"
wp menu item add-post main-menu $(wp post list --post_type=page --field=ID | head -1)
wp menu location assign main-menu primary

Disable File Editing in Admin (hardening)

wp config set DISALLOW_FILE_EDIT true --raw
wp config set DISALLOW_FILE_MODS true --raw

Disable Auto-Updates

wp config set AUTOMATIC_UPDATER_DISABLED true --raw

Run Site Health Checks

Requires the doctor command package:

wp package install wp-cli/doctor-command:@stable
wp doctor check --all

Generate REST API Application Password

For external services that need to push to your site:

wp user application-password create "$WP_ADMIN_USER" "Local Dev"

Set Site Description

wp option update blogdescription "A site built with newwp.sh"

Install a Language

wp language core install en_GB --activate

Troubleshooting

Missing credentials file at /Users/.../newwp.env

You haven't created the credentials file yet β€” see Installation step 2.

Site 'mysite' already exists at ~/Herd/mysite

The script refuses to overwrite existing sites. Either pick a new name or uninstall the old site first.

Error establishing a database connection

  • Verify MySQL is running: brew services list or check Herd's UI
  • Verify DB_USER and DB_PASS in ~/.config/newwp.env match your actual MySQL credentials
  • Test manually: mysql -u root -p

wp: command not found

Install WP-CLI:

brew install wp-cli

herd: command not found

Install Herd from herd.laravel.com and make sure it's running.

The browser opens but shows a security warning

Herd's HTTPS certs need to be trusted. Run:

herd trust

Plugins aren't getting installed

  • Verify ~/Scripts/zips/ exists and contains .zip files
  • Plugins downloaded from WordPress.org sometimes come wrapped in a parent folder β€” the script handles __MACOSX/ cleanup automatically

Uninstalling a Site

There's no built-in uninstaller, but it's a three-step manual process:

# 1. Drop the database
wp db drop --yes --path=~/Herd/mysite

# 2. Remove the site directory
rm -rf ~/Herd/mysite

# 3. Remove the Herd HTTPS cert (optional)
herd unsecure mysite

⚠️ This is destructive and irreversible. Double-check the site name before running.


Author: Adam Lea License: Personal use

About

A zero-friction WordPress site bootstrapper for local development with Laravel Herd. Spin up a fully-configured, secured, plugin-loaded WordPress site at https://<sitename>.test with a single command.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages