Skip to content

Instantly share code, notes, and snippets.

@vburlak
Forked from teledirigido/wpinstall.sh
Last active April 2, 2024 08:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vburlak/e71e85f83079e10ef296529895405c28 to your computer and use it in GitHub Desktop.
Save vburlak/e71e85f83079e10ef296529895405c28 to your computer and use it in GitHub Desktop.
Download and Install Wordpress and Roots/Sage theme 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) Install required-dev plugins
wp plugin install disable-comments --activate
wp plugin install disable-search --activate
wp plugin install monster-widget --activate
wp plugin install advanced-custom-fields --activate
# 6) Install Roots/Sage theme via latest GH release
wget https://github.com/roots/sage/zipball/master -O roots.zip
wp theme install roots.zip --activate
# 7) Compile Sage assets
cd wp-content/themes/sage
npm install && bower install
gulp
# 7) 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