Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Last active December 14, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mannieschumpert/5026289 to your computer and use it in GitHub Desktop.
Save mannieschumpert/5026289 to your computer and use it in GitHub Desktop.
Bash function for installing WordPress
wp() {
# Needs two parameters
# Parameter 1 is the account name, or install directory
# Parameter 2 will set the database password
cd ~/../home/${1}/public_html # go to install directory
wget http://wordpress.org/latest.tar.gz # get latest WordPress
tar xfz latest.tar.gz # unpack
chown -R ${1} wordpress # change all files in wordpress to be owned by user (solves a problem when installing as root)
chgrp -R ${1} wordpress # change associated group (solves a problem when installing as root)
mv wordpress/* ./ # move all files from /wordpress to the root directory
rmdir wordpress # remove the wordpress folder
rm -f latest.tar.gz # remove the tar package
# Set up the database ...
pass=$rootmysqlpassword
mysql -uroot -p$pass -e "create database $1_wrdp"
mysql -uroot -p$pass -e "grant all on $1_wrdp.* to '$1'@'localhost' identified by '$2'"
}
@mannieschumpert
Copy link
Author

This simplifies the process of installing WordPress and creating a database for the installation.

This particular function is made to be used when logged in as root. I'm not sure how universal it is, but it works on my VPS. If anything, you might have to change the directory structure in line 5.

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