Skip to content

Instantly share code, notes, and snippets.



Forked from chrisjlee/
Last active Dec 18, 2015
What would you like to do?
Install latest wordpress to current directory
#!/usr/bin/env bash
echo "Database Name: "
read -e DBNAME
echo "Database User: "
read -e DBUSER
echo "Database Password: "
read -e DBPASS
echo -e "
DB Name: '$DBNAME'
DB User: '$DBUSER'
DB Pass: '$DBPASS'
run install? (Y/n)"
read -e RUN
if [ "$RUN" == n ] ; then
#download wordpress
echo "Downloading wordpress..."
curl -O
#unzip wordpress
echo -e "Extracting wordpress to: \n$(pwd)"
tar -zxf latest.tar.gz
#change dir to wordpress
cd wordpress
#copy file to parent dir
cp -rf . ..
#move back to parent dir
cd ..
#remove files from wordpress folder
rm -R wordpress
#create wp config
echo "Creating wp-config.php..."
cp wp-config-sample.php wp-config.php
#set database details with perl find and replace
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
#Update the secret key in wp-config.php
echo "Downloading and updating secret key..."
EXISTINGKEYS='put your unique phrase here'
printf '%s\n' "g/$EXISTINGKEYS/d" a "$SECRETKEYS" . w | ed -s wp-config.php
#create uploads folder and set permissions
echo "Creating wp-content/uploads"
mkdir wp-content/uploads
chmod 777 wp-content/uploads
#remove zip file
echo "removing latest.tar.gz"
rm latest.tar.gz

This comment has been minimized.

Copy link

@deleuzer deleuzer commented Jun 4, 2013

You could do this without needing to call out remotely to get salts, a potential security concern with:

for i in $(seq 1 $(grep -c "put your unique phrase here" wp-config-s.php));
salt=$(pwgen -y -n -s 64 -N 1) &&
sed -i "0,/put your unique phrase here/s/put your unique phrase here/$salt/" wp-config-s.php;


This comment has been minimized.

Copy link
Owner Author

@dhornbein dhornbein commented Jun 4, 2013

Trouble is that pwgen might not be installed (not a huge issue). Also, how do I restrict it from making strings with single quotes ', these break the php code in wp-config.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.