Created
December 21, 2019 08:11
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
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
Requires a local development environment. I use https://laravel.com/docs/6.x/valet, and
~/development/valet-sitesis where I've runvalet park.Usage:
chmod 755 /location/to/wp-createecho $PATHto see where you could put it./usr/local/binis a good option, else you can put anywhere and add to your PATH's if you know how.~/development/valet-sitesin the script to wherever you want sites to be added.wp-create sitenameto havesitename.testautomatically created for you, opened in the browser, with the usernameaand passwordp.