Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download and Install Wordpress via WP-CLI
#!/bin/bash
# This bash script works JUST with WP-CLI
# You can get it from here:
# http://wp-cli.org/
#
# If you don't know what to do with this file:
#
# 1) Install wp-cli on your workspace
# 2) Create a file call wpinstall.sh
# 3) Copy the whole content of this file on your wpinstall.sh file
# 4) Save your file and add this: chmod +x wpinstall.sh your file. Otherwise you won't be able to run the script
# 5) run your file with ./wpinstall.sh
# 6) While install have a nice cup of hot water or cold.
# Your database credentials
DBNAME=[dbname]
DBUSER=[dbuser]
DBPASS=[dbpass]
DBHOST=[dbhost]
# Your next wordpress site credentials
WPUSER=[wpuser]
WPPASS=[wppass]
WPEMAIL=[wpemail]
WPURL=[wpurl]
WPTITLE=[wptitle]
# 1) Download Wordpress
echo 'Downloading Wordpress'
wp core download
# 2) Generate wp-config.php / Setting DB
echo 'Creating wp-config.php'
mysql -u $DBUSER -p$DBPASS -e "CREATE DATABASE IF NOT EXISTS $DBNAME;"
wp core config --dbname=$DBNAME --dbuser=$DBUSER --dbpass=$DBPASS --dbhost=$DBHOST
# 3) Install Wordpress after wp-config.php has been created
echo 'Installing Wordpress'
wp core install --url=$WPURL --title=$WPTITLE --admin_user=$WPUSER --admin_password=$WPPASS --admin_email=$WPEMAIL
# 4) Clean up installation, sorry guys
echo 'Cleaning wp-content/themes folders and plugins folders'
rm -rf wp-content/themes/twentyfifteen
rm -rf wp-content/themes/twentyfourteen
rm -rf wp-content/themes/twentysixteen
rm -rf wp-content/plugins/hello.php
# 5) All good
echo 'Dream as if you will live forever. Live as if you will die today.'
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.