Created
October 22, 2012 23:06
-
-
Save hermpheus/3935325 to your computer and use it in GitHub Desktop.
LEMP: Create Fresh WordPress Subdomain Install
This file contains 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
#!/bin/bash | |
# $1 = site name | |
# $2 = user | |
# $3 = password | |
# Create working folder | |
mkdir /tmp/getWP | |
cd /tmp/getWP | |
## Download latest (stable) version of WordPress | |
curl -O http://wordpress.org/latest.tar.gz | |
## Uncompress | |
tar -xf latest.tar.gz | |
cd /tmp/getWP/wordpress/ | |
## Edit wp-config | |
mv wp-config-sample.php wp-config.php | |
sed -i "s/username_here/$2/g" wp-config.php | |
sed -i "s/password_here/$3/g" wp-config.php | |
sed -i "s/database_name_here/$1/g" wp-config.php | |
## Add to Apache config | |
sudo touch /etc/nginx/sites-available/$1 | |
sudo sed -i "$ a \ | |
server {\n\ | |
server_name $1.DOMAIN.COM;\n\ | |
root /var/www/$1.DOMAIN.COM/public;\n\ | |
include global/restrictions.conf;\n\ | |
include global/wordpress.conf;\n\ | |
}\n" /etc/nginx/sites-available/$1 | |
sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/$1 | |
## add to hosts | |
#sudo sed -i "$ a \ | |
# \n127.0.0.1 $1.localhost.com \n\ | |
#" /etc/hosts | |
## Create Database | |
CMD="CREATE DATABASE $1" | |
/usr/bin/mysql --host=localhost -uroot -pYOURPASSWORD -e "$CMD" | |
CMD="GRANT usage ON *.* to $2@localhost identified by '$3'" | |
/usr/bin/mysql --host=localhost -uroot -pYOURPASSWORD -e "$CMD" | |
CMD="GRANT all PRIVILEGES ON $1.* to $2@localhost" | |
/usr/bin/mysql --host=localhost -uroot -pYOURPASSWORD -e "$CMD" | |
## Move working folder to ~/Sites | |
mkdir /var/www/$1.DOMAIN.COM | |
mkdir /var/www/$1.DOMAIN.COM/public | |
mkdir /var/www/$1.DOMAIN.COM/logs | |
sudo mv /tmp/getWP/wordpress /var/www/$1.DOMAIN.COM/public | |
sudo chown -R www-data:www-data /var/www/$1.DOMAIN.COM | |
## Restart nginx | |
sudo service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment