Skip to content

Instantly share code, notes, and snippets.

@slushman
Forked from nicomollet/wp_auto_install.sh
Last active December 14, 2018 03:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slushman/4583a3fac5ee8fa4d3fb34483ae12a2b to your computer and use it in GitHub Desktop.
Save slushman/4583a3fac5ee8fa4d3fb34483ae12a2b to your computer and use it in GitHub Desktop.
WP-CLI auto install local development site script
#!/bin/bash
# Get the required project variables
printf "Project name: "
read PROJECT_NAME
printf "Project folder name: "
read PROJECT_FOLDER
printf "Database Name: "
read DB_NAME
printf "Database Password: "
read DB_PASSWORD
# Install WordPress and create the wp-config.php file...
wp core download --path=$PROJECT_FOLDER
wp core config --path=$PROJECT_FOLDER --dbname=$DB_NAME --dbuser="root" --dbpass=$DB_PASSWORD --dbhost="localhost" --dbprefix="wp_" --extra-php <<PHP
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
PHP
# Go in the install directory
cd $PROJECT_FOLDER
# Create the database
wp db create
# Install WordPress
wp core install --title=$PROJECT_NAME --url="http://"$PROJECT_FOLDER".test" --admin_user="slushman" --admin_email="chris@slushman.com" --admin_password="password"
# Update WordPress options
wp option update permalink_structure '/%postname%/'
# Install and activate defaults plugins
wp plugin install gutenberg debug-bar debug-bar-extender debug-bar-console debug-bar-plugin-activation --activate
# Install defaults plugins
wp plugin install wordpress-seo
# Update plugins
wp plugin update --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment