Skip to content

Instantly share code, notes, and snippets.

@jonathonsim
Last active January 14, 2020 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathonsim/09b9fc5ca9c387fed01cdcb618df1520 to your computer and use it in GitHub Desktop.
Save jonathonsim/09b9fc5ca9c387fed01cdcb618df1520 to your computer and use it in GitHub Desktop.
Sript to install a test copy of wp for benchmarking and testing. Usage is ` curl https://gist.githubusercontent.com/jonathonsim/09b9fc5ca9c387fed01cdcb618df1520/raw/install-test-wp.sh | bash -s -- wpdb dbuser dbpass`
#!/bin/bash
if [[ -z $5 ]]; then
echo "Usage $0 url dbhost dbname dbuser dbpass"
exit 1
fi
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mkdir ~/bin
mv wp-cli.phar ~/bin/wp
cd ~/public_html
wp core download #Download wordpress
#Generate a random table prefix. This is a good security enhancement
PREFIX=wp_$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 11 | head -n 1)_
#Create a configuration file.
wp config create --dbhost=$2 --dbname=$3 --dbuser=$4 --dbpass="$5" --dbprefix=$PREFIX
wp core install --url=$1 --title=test --admin_user=admin --admin_password=$PREFIX --admin_email=test@idealstack.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment