Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash Script to Install WordPress from a Local Machine to Remote Server
#!/bin/bash
# Update variables as needed.
SSH_REMOTE_INFO="username@remotehost"
WP_HOME_DIR="path/to/remote/wp/homedir"
DB_NAME="db_name"
DB_USER_NAME="db_user_name"
DB_USER_PASS="db_user_pass"
DB_HOST="localhost"
SITE_URL="http://example.com"
SITE_TITLE="Site Title"
ADMIN_EMAIL="adminemail@example.com"
ADMIN_USER_NAME="myadminusername"
ADMIN_USER_PASS="mypassword1"
# Download and extract WordPress to home directory.
wp core download --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Create and configure wp-config.php file
wp core config --dbname=$DB_NAME --dbuser=$DB_USER_NAME --dbpass=$DB_USER_PASS --dbhost=$DB_HOST --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Initiate ”Famous WordPress 5-Minute Install".
wp core install --url=$SITE_URL --title="$SITE_TITLE" --admin_user=$ADMIN_USER_NAME --admin_password=$ADMIN_USER_PASS --admin_email=$ADMIN_EMAIL --skip-email --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Uninstall Hello Dolly Plugin
wp plugin uninstall hello --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Activating Akismet Plugin
wp plugin activate akismet --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Installing Default Plugins
wp plugin install jetpack --activate --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
wp plugin install wp-super-cache --activate --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
wp plugin install wordpress-seo --activate --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
wp plugin install amp --activate --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
# Configure Rewrite Rule
wp rewrite structure '/%postname%/' --ssh=$SSH_REMOTE_INFO --path=$WP_HOME_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.