Created
January 28, 2013 15:35
-
-
Save JosephRedfern/4656509 to your computer and use it in GitHub Desktop.
Nginx Site Aded
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 | |
#path to folder containing folders referenced by nginx server blocks | |
SERVERPATH="/var/www" | |
#name of logs folder | |
LOGFOLDER="logs" | |
#name of www folder (i.e. folder where web files are held) | |
WWWFOLDER="public_html" | |
#name of nginx sites folder | |
NGINXFOLDER="/etc/nginx/sites-enabled" | |
#END CONFIGUARABLES | |
set -e | |
echo "nginx server block creator" | |
echo -n "creating $SERVERPATH/$1/..." | |
mkdir "$SERVERPATH/$1" | |
echo "Done!" | |
echo -n "creating $SERVERPATH/$1/$LOGFOLDER..." | |
mkdir "$SERVERPATH/$1/$LOGFOLDER" | |
echo "Done!" | |
echo -n "creating $SERVERPATH/$1/$WWWFOLDER..." | |
mkdir "$SERVERPATH/$1/$WWWFOLDER" | |
echo "Done!" | |
touch $NGINXFOLDER/$1 | |
CONFIG="server { | |
server_name www.$1 $1\; | |
access_log $SERVERPATH/$1/$LOGFOLDER/access.log\; | |
error_log $SERVERPATH/$1/$LOGFOLDER/error.log\; | |
root $SERVERPATH/$1/$WWWFOLDER\; | |
location / { | |
index index.html index.htm index.php\; | |
} | |
autoindex on\; | |
include enable_php\; | |
} | |
" | |
echo $CONFIG > $NGINXFOLDER/$1 | |
/etc/init.d/nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment