Skip to content

Instantly share code, notes, and snippets.

@benmay
Created July 9, 2013 11:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benmay/5956803 to your computer and use it in GitHub Desktop.
Save benmay/5956803 to your computer and use it in GitHub Desktop.
Bash script used on dev server to create new WordPress sites.
#!/bin/sh
# Set DB Constants
DBHOST="localhost"
DBUSER="root"
DBPASS="123"
DBNAME="wp_$1"
# Set WP Constants
ADMIN_NAME="my_admin_account"
ADMIN_PASS="admin_123"
ADMIN_EMAIL="me@me.com"
SITE_DOMAIN="http://my-dev-server/$1"
SITE_TITLE=$2
# Create the DB if it doesnt exist (MySQL user would need create access)
mysql --verbose --user=$DBUSER -p$DBPASS --execute="create database IF NOT EXISTS $DBNAME"
# Create the directory
mkdir $1
# Change Director, and do wp-cli stuff.
cd $1 && {
/root/.composer/bin/wp core download
/root/.composer/bin/wp core config --dbname=$DBNAME --dbuser=$DBUSER --dbpass=$DBPASS
/root/.composer/bin/wp core install \
--url=$SITE_DOMAIN \
--title=$SITE_TITLE \
--admin_name=$ADMIN_NAME \
--admin_email=$ADMIN_EMAIL \
--admin_password=$ADMIN_PASS
/root/.composer/bin/wp plugin install wordpress-seo --activate
/root/.composer/bin/wp plugin install advanced-custom-fields --activate
}
# Dev permissions
chown -R www_intranet $1
chmod -R 755 $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment