Skip to content

Commit 56051ca

Browse files
committed
cr
1 parent 80c5281 commit 56051ca

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

create_nginx_vhost/create.sh

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,18 @@ if [ -e $NGINX_CONFIG$DOMAIN ]; then
3636
exit;
3737
fi
3838

39-
#Replace dots with underscores
40-
SITE_DIR=`echo $DOMAIN | $SED 's/\./_/g'`
41-
42-
# Now we need to copy the virtual host template
43-
CONFIG=$NGINX_CONFIG/$DOMAIN.conf
44-
sudo cp $CURRENT_DIR/virtual_host.template $CONFIG
45-
sudo $SED -i "s/DOMAIN/$DOMAIN/g" $CONFIG
46-
sudo $SED -i "s!ROOT!$WEB_DIR/$SITE_DIR!g" $CONFIG
47-
48-
# set up web root
49-
sudo mkdir $WEB_DIR/$SITE_DIR
50-
sudo chown vagrant:vagrant -R $WEB_DIR/$SITE_DIR
51-
sudo chmod 600 $CONFIG
52-
53-
# create symlink to enable site
54-
sudo ln -s $CONFIG $NGINX_SITES_ENABLED/$DOMAIN.conf
55-
56-
# reload Nginx to pull in new config
57-
sudo /usr/local/nginx/sbin/nginx -s reload
58-
59-
# put the template index.html file into the new domains web dir
60-
sudo cp $CURRENT_DIR/index.html.template $WEB_DIR/$SITE_DIR/index.html
61-
sudo $SED -i "s/SITE/$DOMAIN/g" $WEB_DIR/$SITE_DIR/index.html
62-
sudo chown vagrant:vagrant $WEB_DIR/$SITE_DIR/index.html
6339

6440
### create nginx virtual host
65-
SITE=(m.$DOMAIN agent.$DOMAIN imc.$DOMAIN)
41+
SITE=($DOMAIN m.$DOMAIN agent.$DOMAIN imc.$DOMAIN)
6642
for a in "${SITE[@]}"; do
43+
SITE_DIR=`echo $a | $SED 's/\./_/g'`
6744
CONFIGM=$NGINX_CONFIG/$a.conf
6845
sudo cp $CURRENT_DIR/virtual_host.template $CONFIGM
6946
sudo $SED -i "s/DOMAIN/$a/g" $CONFIGM
47+
sudo $SED -i "s!ROOT!$WEB_DIR/$SITE_DIR!g" $CONFIGM
7048

71-
sudo $SED -i "s!ROOT!$WEB_DIR/$a!g" $CONFIGM
72-
73-
sudo mkdir $WEB_DIR/$a
74-
sudo chown vagrant:vagrant -R $WEB_DIR/$a
49+
sudo mkdir $WEB_DIR/$SITE_DIR
50+
sudo chown vagrant:vagrant -R $WEB_DIR/$SITE_DIR
7551
sudo chmod 600 $CONFIGM
7652

7753
sudo ln -s $CONFIGM $NGINX_SITES_ENABLED/$a.conf
@@ -80,9 +56,9 @@ for a in "${SITE[@]}"; do
8056
sudo /usr/local/nginx/sbin/nginx -s reload
8157

8258
# put the template index.html file into the new domains web dir
83-
sudo cp $CURRENT_DIR/index.html.template $WEB_DIR/$a/index.html
84-
sudo $SED -i "s/SITE/$a/g" $WEB_DIR/$a/index.html
85-
sudo chown vagrant:vagrant $WEB_DIR/$a/index.html
59+
sudo cp $CURRENT_DIR/index.html.template $WEB_DIR/$SITE_DIR/index.html
60+
sudo $SED -i "s/SITE/$a/g" $WEB_DIR/$SITE_DIR/index.html
61+
sudo chown vagrant:vagrant $WEB_DIR/$SITE_DIR/index.html
8662
done
8763

8864
### create mysql database

0 commit comments

Comments
 (0)