Skip to content

Instantly share code, notes, and snippets.

@basoro
Created January 18, 2018 10:25
Show Gist options
  • Save basoro/1de1e02f4791f560ea608ebc07259c64 to your computer and use it in GitHub Desktop.
Save basoro/1de1e02f4791f560ea608ebc07259c64 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]
then
echo "Usage: setup-vhost <hostname> (without the www. prefix)"
exit
fi
# Checking Permissions and making directorys
mkdir "/var/www/$1"
chown nginx:nginx -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/www/$1-access.log;
error_log /var/www/$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