Last active
December 14, 2015 04:09
-
-
Save mannieschumpert/5026289 to your computer and use it in GitHub Desktop.
Bash function for installing WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.