Created
January 18, 2018 10:25
-
-
Save basoro/1de1e02f4791f560ea608ebc07259c64 to your computer and use it in GitHub Desktop.
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 | |
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