Created
July 15, 2012 01:58
-
-
Save tracend/3114416 to your computer and use it in GitHub Desktop.
Nginx new site 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 | |
# some code copied from http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/ | |
if [ -z "$1" ] | |
then | |
echo "Usage: nginx-site <hostname> (without the www. prefix)" | |
exit | |
fi | |
# Checking Permissions and making directorys | |
mkdir "/var/www/$1" | |
chown root:root -R "/var/www/$1" | |
# Setting up Nginx mapping | |
cat > "/etc/nginx/conf.d/$1.conf" <<END | |
server { | |
server_name $1 www.$1; | |
root /var/www/$1; | |
include php; | |
access_log /var/log/nginx/$1-access.log; | |
error_log /var/log/nginx/$1-error.log; | |
} | |
END | |
service nginx reload | |
echo vhost created successfully, upload files to /var/www/$1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment