Created
July 23, 2020 21:41
-
-
Save mage1k99/9bf4d1c324a0a5d606af18270a83a1e7 to your computer and use it in GitHub Desktop.
Automation Script
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 | |
siteDir="/var/www/$1" | |
echo 'Creating directory at /var/www/ for '$1'' | |
mkdir -p $siteDir | |
echo 'Directory created '$siteDir' ' | |
echo "changing ownership of directory" | |
chown www-data:www-data $siteDir -Rv | |
echo "creating an index.html file" | |
echo "Hello from $1" >> $siteDir/index.html | |
echo "file created" | |
echo 'creating virtual host for '$1' in apache config directory' | |
echo '<VirtualHost *:808> \n ServerName '$1' \n ServerAlias www.'$1' \n DocumentRoot /var/www/'$1' \n <Directory /var/www/'$1'> \n AllowOverride All \n </Directory> \n </VirtualHost>' >> /etc/apache2/sites-available/$1.conf | |
cat /etc/apache2/sites-available/$1.conf | |
echo "enabling site" | |
a2ensite $1 | |
echo "reloading apache" | |
service apache2 reload | |
echo "apache reloaded" | |
echo 'creating configuration for '$1' in nginx config directory ' | |
echo 'server { \n server_name '$1'; \n location / { \n proxy_pass http://127.0.0.1:808; \n proxy_set_header Host $host; \n proxy_set_header X-Real-IP $remote_addr; \n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \n proxy_set_header X-Forwarded-Proto $scheme; \n } \n }' >> /etc/nginx/sites-available/$1 | |
echo 'configuration created for '$1' in nginx' | |
cat /etc/nginx/sites-available/$1 | |
echo 'Creating symbolic links for '$1' ' | |
ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/ -v | |
echo 'symbolic link created' | |
nginx -t | |
echo "stoping nginx" | |
service nginx stop | |
echo "starting ngnix" | |
service nginx start | |
echo "mission completed" | |
echo "Have some water" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment