Skip to content

Instantly share code, notes, and snippets.

@sabbir1991
Created October 16, 2017 08:44
Show Gist options
  • Save sabbir1991/cfa79b9c5942a568ca244fdbdf973f3e to your computer and use it in GitHub Desktop.
Save sabbir1991/cfa79b9c5942a568ca244fdbdf973f3e to your computer and use it in GitHub Desktop.
Autometic WP installation Process using bash
#!/bin/bash
clear
# Remove/Uninstall process
echo "Start WordPress installation"
if [[ $1 == "remove" ]]; then
# Grab the project name
if [[ -z $2 ]]; then
echo "WP Project to remove: "
read -e projectname
else
projectname=$2
fi
projectDirectory="/Users/sabbir/Documents/sites/$projectname"
if [[ ! -d $projectDirectory ]]; then
echo "$projectDirectory directory not exists"
exit
fi
wp db drop --yes --path=$projectDirectory
rm -rf $projectDirectory
echo "$projectname removed completely"
exit
fi
if [ -z "$1" ]; then
# accept user input for the databse name
echo "Project Name(no space): "
read -e projectname
else
projectname=$1
fi
mkdir -p "/Users/sabbir/Documents/sites/$projectname"
cd "/Users/sabbir/Documents/sites/$projectname"
# download the WordPress core files
wp core download
# create the wp-config file with our standard setup
wp core config --dbname=$projectname --dbuser='root' --dbpass='root' --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
PHP
# create database, and install WordPress
wp db create
wp core install --url="http://localhost/$projectname" --title="WordPress Localhost Site" --admin_user="admin" --admin_password="password" --admin_email="sabbi@wedevs.com"
# discourage search engines
wp option update blog_public 0
# this is required for the .htaccess
touch wp-cli.local.yml
echo "apache_modules:
-mod_rewrite
" > wp-cli.local.yml
# set pretty urls
wp rewrite structure '/%postname%/' --hard
wp rewrite flush --hard
rm wp-cli.local.yml
# delete akismet and hello dolly
wp plugin delete akismet
wp plugin delete hello
wp plugin install debug-bar --activate
wp plugin install debug-bar-console --activate
wp plugin install rewrite-rules-inspector --activate
wp plugin install post-meta-inspector --activate
if [[ $2 == "woo" ]]; then
wp plugin install woocommerce --activate
fi
# install starter theme
# if [ ! -z "$2" ]; then
# wp theme install ~/epsilon.zip --activate
# fi
echo "================================================================="
echo "Installation is complete. open browse http://localhost/$projectname/wp-admin/"
echo "Admin User: admin"
echo "Admin Pass: password"
echo "================================================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment