Skip to content

Instantly share code, notes, and snippets.

@mxmilkiib
Created July 2, 2013 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxmilkiib/5912956 to your computer and use it in GitHub Desktop.
Save mxmilkiib/5912956 to your computer and use it in GitHub Desktop.
WP Install Base
#!/bin/bash
# this is a work in progress! NOT for production.
# requires wp-cli
# usage: wp-base-install
# or: ./wp-base-install.sh
# Bits of inspiration from https://gist.github.com/2853221
# to look at: http://www.servercobra.com/automated-wordpress-install-with-nginx-script/
# Download WordPress
echo "Project name (lowercase):"
read -e PROJECT
cd /var/www
mkdir $PROJECT && cd $_
wp core download
# Set up config.php and database
mv wp-config-sample.php wp-config.php
echo “Database Name: ”
read -e DBNAME
echo “Database User: ”
read -e DBUSER
echo “Database Password: ”
read -s DBPASS
echo “Editing wp-config.php...”
sed -i 's/database_name_here/'$DBNAME'/g' ./wp-config.php
sed -i 's/username_here/'$DBUSER'/g' ./wp-config.php
sed -i 's/password_here/'$DBPASS'/g' ./wp-config.php
Q1="CREATE DATABASE IF NOT EXISTS $DBNAME;"
Q2="GRANT ALL ON *.* TO '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASS';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
MYSQL=`which mysql`
$MYSQL -uroot -p -e "$SQL"
# Install site
echo “Url: ”
read -e SITEURL
echo “Title: ”
read -e SITETITLE
echo "E-mail: "
read -e SITEMAIL
echo “Site Password: ”
read -s SITEPASS
echo "Install site? (y/n)"
read -e SITERUN
if [ "$SITERUN" != "y" ] ; then
exit
else
wp core install --url=$SITEURL --title=$SITETITLE --admin_email=$SITEMAIL --admin_password=$SITEPASS
# [--admin_name=username]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment