Skip to content

Instantly share code, notes, and snippets.

@thegallagher
Created July 29, 2016 06:34
Show Gist options
  • Save thegallagher/816c8aed3381d5970d893cdd729b0f4b to your computer and use it in GitHub Desktop.
Save thegallagher/816c8aed3381d5970d893cdd729b0f4b to your computer and use it in GitHub Desktop.
Install WordPress on a devbox
#!/usr/bin/env bash
set -e
# Config
NAME=`basename "$PWD"`
SERVER_URL="http://localhost/$NAME"
ADMIN_USER="devbox"
ADMIN_PASS="devbox"
ADMIN_EMAIL="[email protected]"
DB_USER="root"
DB_PASS="devbox"
DB_NAME="$NAME"
# Do not run the script if the current path is not empty, except for hidden file
if [ "$(ls $PWD)" ]; then
echo "$PWD is not empty."
exit
fi
# Create the database
echo "Creating the database..."
mysql --user="$DB_USER" --password="$DB_PASS" -e "CREATE DATABASE \`$DB_NAME\`;"
# Download and install WordPress
echo "Installing WordPress..."
wp core download
wp core config --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASS"
wp core install --url="$SERVER_URL" --title="$NAME" --admin_user="$ADMIN_USER" --admin_password="$ADMIN_PASS" --admin_email="$ADMIN_EMAIL" --skip-email
# Install plugins
echo "Installing sync plugins..."
wp plugin install --activate "https://github.com/wp-sync-db/wp-sync-db/archive/master.zip"
wp plugin install --activate "https://github.com/wp-sync-db/wp-sync-db-media-files/archive/master.zip"
wp plugin install --activate "https://github.com/wp-sync-db/wp-sync-db-cli/archive/master.zip"
# Install starter theme
echo "Installing starter theme..."
git clone https://github.com/roots/sage.git "wp-content/themes/$NAME"
wp theme activate "$NAME"
# Clean up plugins and themes
echo "Removing junk themes and plugins..."
wp plugin uninstall hello
wp plugin uninstall akismet
wp theme delete twentyfourteen
wp theme delete twentyfifteen
wp theme delete twentysixteen
# Done
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment