Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from ajmorris/SetupWordPress.sh
Created September 20, 2017 23:46
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 jimboobrien/77915f82bcb17c6f88886ace7a7b3cca to your computer and use it in GitHub Desktop.
Save jimboobrien/77915f82bcb17c6f88886ace7a7b3cca to your computer and use it in GitHub Desktop.
printf "MySQL User: "
read MYSQLUSER
if [ "$MYSQLUSER" = "" ]; then
set MYSQLUSER = "root"
fi
printf "MySQL Password: "
read MYSQLPWD
if [ "$MYSQLPWD" = "" ]; then
set MYSQLPWD = "asdfasdf"
fi
printf "Database Host: (e.g. 127.0.0.1)"
read NEWHOST
if [ "$NEWHOST" = "" ]; then
set NEWHOST = "127.0.0.1"
fi
printf "What would you like to name your new database (i.e. newwpdb)?"
read NEWDB
echo "CREATE DATABASE $NEWDB; GRANT ALL ON $NEWDB.* TO 'root'@'localhost';" | /usr/local/bin/mysql -uroot -pollie1
cp -n ./wp-config-sample.php ./wp-config.php
SECRETKEYS=$(curl -L https://api.wordpress.org/secret-key/1.1/salt/)
EXISTINGKEYS='put your unique phrase here'
printf '%s\n' "g/$EXISTINGKEYS/d" a "$SECRETKEYS" . w | ed -s wp-config.php
DBUSER=$"username_here"
DBPASS=$"password_here"
DBNAME=$"database_name_here"
DBHOST=$"localhost"
sed -i '' -e "s/${DBUSER}/${MYSQLUSER}/g" wp-config.php
sed -i '' -e "s/${DBPASS}/${MYSQLPWD}/g" wp-config.php
sed -i '' -e "s/${DBNAME}/${NEWDB}/g" wp-config.php
sed -i '' -e "s/${DBHOST}/${NEWHOST}/g" wp-config.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment