add scripts to create nginx virtual host for service

This commit is contained in:
2020-12-20 20:18:29 -06:00
parent ef2564ed53
commit b794c5e8a9
2 changed files with 53 additions and 0 deletions

26
nginxify Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
SERVER_NAME=$1
PORT=$2
NGINX_CONFIG=/etc/nginx
AVAILABLE_SITES="$NGINX_CONFIG/sites-available"
ENABLED_SITES="$NGINX_CONFIG/sites-enabled"
NGINX_CONF_TEMPLATE=nginx.conf.template
NGINX_CONF_NAME="$SERVER_NAME.conf"
NGINX_LOGS=/var/log/nginx
cp $NGINX_CONF_TEMPLATE "$AVAILABLE_SITES/$NGINX_CONF_NAME"
cd $AVAILABLE_SITES
sed -i "s/@SERVER_NAME@/$SERVER_NAME/g" $NGINX_CONF_NAME
sed -i "s/@PORT@/$PORT/g" $NGINX_CONF_NAME
cd $ENABLED_SITES
ln -s "../sites-available/$NGINX_CONF_NAME" .
mkdir -p "$NGINX_LOGS/$SERVER_NAME"
service nginx reload