Skip to content

Instantly share code, notes, and snippets.

@tracend
Created July 15, 2012 01:58
Show Gist options
  • Save tracend/3114416 to your computer and use it in GitHub Desktop.
Save tracend/3114416 to your computer and use it in GitHub Desktop.
Nginx new site script
#!/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