Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Created December 21, 2019 08:11
Show Gist options
  • Save WPprodigy/2ceeeaf631a56ad9c3dd4498813f227e to your computer and use it in GitHub Desktop.
Save WPprodigy/2ceeeaf631a56ad9c3dd4498813f227e to your computer and use it in GitHub Desktop.
WP local site creation script. Made for use with https://laravel.com/docs/6.x/valet
#!/bin/bash
# Usage: wp-create sitename
if [ $# -eq 0 ]; then
echo "Need to provide the directory name to be created."
exit 1
fi
# set up new folder to house the WP install
cd ~/development/valet-sites
mkdir $1 && cd $1
# dowload wordpress and setup to use new database
wp core download
wp config create --dbname=$1 --dbuser=root --dbpass=''
wp config set WP_DEBUG true --raw --type=constant
wp config set WP_DEBUG_DISPLAY false --raw --type=constant
wp config set WP_DEBUG_LOG true --raw --type=constant
wp config set SCRIPT_DEBUG false --raw --type=constant
wp config set JETPACK_DEV_DEBUG true --raw --type=constant
wp db create
wp core install --url=$1.test --title=$1 --admin_user=a [email protected] --admin_password=p
echo -e "Success: $1.test created."
# make https, will ask for a pw and restart the server
echo -e "Note: Enter your password so we can secure the site with a local SSL cert:"
valet secure $1
# delete Hello Dolly & Akismet
wp plugin delete hello
wp plugin delete akismet
# install and activate Query Monitor
wp plugin install query-monitor && wp plugin activate query-monitor
# open the site in default browser
valet open $1
@WPprodigy
Copy link
Author

Also pairs well with wp-remove script below for deleting the sites :)

#!/bin/bash

if [ $# -eq 0 ]; then
    echo "Need to provide the directory to be removed."
    exit 1
fi

# go to the valet sites folder
cd ~/development/valet-sites/$1

# remove the database
wp db drop --yes

# trash the folder
trash ~/development/valet-sites/$1

echo -e "Success: $1.test site removed."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment