Last active
November 25, 2015 20:51
-
-
Save fliphess/087ce811cf77675a225f to your computer and use it in GitHub Desktop.
Install wordpress from the commandline using wordpress cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin' | |
INSTALL_WORDPRESS_EXTENSIONS=( | |
"better-wp-security" | |
"disqus-comment-system" | |
"redis-cache" | |
"wp-smushit" | |
"w3-total-cache" | |
"wp-optimize" | |
"disabler" | |
) | |
REMOVE_WORDPRESS_EXTENSIONS=( | |
"hello" | |
) | |
clear | |
echo "===========================================" | |
echo "| Wordpress installer |" | |
echo "===========================================" | |
echo "----> Wordpress install location" | |
read -p "Please enter installation dir -> " DEST_DIR | |
[ -d "${DEST_DIR}" ] || mkdir -pv "${DEST_DIR}" | |
echo | |
echo "----> Base url" | |
read -p "Please enter the base url for wordpress (use / if not in a subdir) -> " BASE_URL | |
echo | |
echo "----> Admin credentials" | |
ADMIN_USER="admin_$(tr -dc < /dev/urandom _A-Z-a-z-0-9 | head -c${1:-5} )" | |
ADMIN_PASS="$(tr -dc < /dev/urandom _A-Z-a-z-0-9 | head -c${1:-32})" | |
read -p "Please enter admin email -> " ADMIN_EMAIL | |
echo | |
echo "----> Database credentials" | |
read -p "Please give database name -> " DBNAME | |
echo | |
read -p "Please give database user -> " DBUSER | |
echo | |
read -p "Please give database host -> " DBHOST | |
echo | |
PASS1="1" ; PASS2="2" | |
while [ "$PASS1" != "$PASS2" ] ; do | |
read -sp "First: Please type database password -> " PASS1 | |
echo | |
read -sp "Second: Re-Type password -> " PASS2 | |
echo | |
done | |
echo "----> Installing wordpress cli" | |
WP="$(pwd)/wp" | |
wget -q -O "${WP}" https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x "$WP" | |
echo "----> Installing wordpress core in ${DEST_DIR}" | |
cd ${DEST_DIR} && $WP core download --force | |
echo "----> Preparing wordpress config file" | |
$WP core config \ | |
--dbhost="${DBHOST}" \ | |
--dbname="${DBNAME}" \ | |
--dbuser="${DBUSER}" \ | |
--dbpass="${PASS2}" | |
echo "----> Setting up wordpress" | |
$WP core install \ | |
--title="Some website" \ | |
--admin_user="${ADMIN_USER}" \ | |
--admin_password="${ADMIN_PASS}" \ | |
--admin_email="${ADMIN_EMAIL}" \ | |
--url="${BASE_URL}" | |
echo "----> Putting htaccess in place" | |
curl -qs https://fliphess.com/htaccess > .htaccess | |
echo "----> Removing plugins" | |
for PLUGIN in ${REMOVE_WORDPRESS_EXTENSIONS[@]} ; do | |
$WP plugin uninstall "${PLUGIN}" | |
done | |
echo "----> Installing plugins" | |
for PLUGIN in ${INSTALL_WORDPRESS_EXTENSIONS[@]} ; do | |
$WP plugin install "${PLUGIN}" | |
done | |
echo "----> Activating all installed plugins" | |
$WP plugin activate --all | |
echo "----> Syncing database" | |
$WP core update-db --all | |
echo "----> Flushing cache" | |
$WP cache flush | |
echo "#########################################################" | |
echo "# Wordpress is installed! #" | |
echo "#########################################################" | |
echo "User: ${ADMIN_USER}" | |
echo "Pass: ${ADMIN_PASS}" | |
echo "Url: ${BASE_URL}" | |
echo "#########################################################" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment