Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
Forked from bgallagh3r/wp.sh
Created August 6, 2012 21:24
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save chrisjlee/3278562 to your computer and use it in GitHub Desktop.
Save chrisjlee/3278562 to your computer and use it in GitHub Desktop.
Wordpress: Bash Install Script
#!/bin/bash
echo “Database Name: ”
read -e dbname
echo “Database User: ”
read -e dbuser
echo “Database Password: ”
read -s dbpass
echo “run install? (y/n)”
read -e run
if [ "$run" == n ] ; then
exit
else
#download wordpress
curl -O http://wordpress.org/latest.tar.gz
#unzip wordpress
tar -zxvf 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
cp wp-config-sample.php wp-config.php
#set database details with perl find and replace
sed -e “s/database_name_here/$dbname/g” wp-config.php
sed -e “s/username_here/$dbuser/g” wp-config.php
sed “s/password_here/$dbpass/g” wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 777 wp-content/uploads
#remove zip file
rm latest.tar.gz
#remove bash script
rm wp.sh
fi
@danielpflood
Copy link

Thank you! This has helped me.

@fsoto
Copy link

fsoto commented Jun 21, 2014

I am getting an error when running this script. I was hoping for perhaps a little help. I get the following

wordpress/wp-config-sample.php
sed: -e expression #1, char 1: unknown command: �' sed: -e expression #1, char 1: unknown command:�'
sed: -e expression #1, char 1: unknown command: `�'

Which of course then does not write the the replacment variable to the config file.

@apisandipas
Copy link

@fsoto I got the same issue, then I realized the quotation marks used in the sed commands are 'curly quotes'. Simply replace them with regular double quotes and it should work.

@cconversion
Copy link

Another installer for perspective: https://gist.github.com/cconversion/cc09b6424c12436b4a33d7e6fb553f35
Tries a few different methods, and packs a bunch of different scripts crudely into the one "All-In-One" installer; but hey it works!
Inspired by, not forked from, the @bgallagh3r gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment