Skip to content

Instantly share code, notes, and snippets.

@edwardleoni
Forked from bgallagh3r/wp.sh
Last active May 14, 2016 21:03
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 edwardleoni/fc416a37ac866877409cf7cb700b9bfc to your computer and use it in GitHub Desktop.
Save edwardleoni/fc416a37ac866877409cf7cb700b9bfc to your computer and use it in GitHub Desktop.
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
dbname=$1
dbuser=$2
dbpass=$3
installationPath=$4
echo "============================================"
echo "A robot is now installing WordPress for you."
echo "============================================"
#download latest wordpress
curl -O https://wordpress.org/latest.tar.gz
#unzip wordpress
tar -zxvf latest.tar.gz
#change dir to wordpress
cd wordpress
#copy files to installation path
cp -rf . $installationPath
#back to root
cd ..
#remove files from wordpress folder
rm -R wordpress
#remove zip file
rm latest.tar.gz
#move to installation path
cd $installationPath
#create wp config
cp wp-config-sample.php wp-config.php
#set database details with perl find and replace
perl -pi -e "s/database_name_here/$dbname/g" wp-config.php
perl -pi -e "s/username_here/$dbuser/g" wp-config.php
perl -pi -e "s/password_here/$dbpass/g" wp-config.php
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/put your unique phrase here/salt()/ge
' wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 775 wp-content/uploads
echo "========================="
echo "Installation is complete."
echo "========================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment