Last active
January 3, 2016 05:19
-
-
Save goromlagche/8414841 to your computer and use it in GitHub Desktop.
A bash script to create server blocks. pass the server_name as a argv with the script.
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 | |
# created by goromlagche | |
DOMAIN=$1 | |
FOLDER=$2 | |
if [ -d /var/www/$DOMAIN ]; | |
then | |
sudo rm -rf /var/www/$DOMAIN | |
fi | |
sudo mv $FOLDER /var/www/$DOMAIN | |
sudo rm -rf savan_com* | |
sudo chown -R ubuntu:www-data /var/www/$DOMAIN | |
if [ ! -f /etc/nginx/sites-available/$DOMAIN ]; | |
then | |
sudo sh -c "echo ' | |
server { | |
listen 80; | |
server_name $DOMAIN; | |
access_log /var/log/nginx/access.$DOMAIN.log; | |
error_log /var/log/nginx/error.$DOMAIN.log; | |
set "$"base /var/www/$DOMAIN; | |
root "$"base; | |
gzip on; | |
#Max upload size | |
client_max_body_size 75M; | |
location / { | |
try_files "$"uri "$"uri/index.html; | |
} | |
}' >> /etc/nginx/sites-available/$DOMAIN" | |
sudo ln -s /etc/nginx/sites-available/$DOMAIN /etc/nginx/sites-enabled/ | |
sudo service nginx reload | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment