Last active
December 19, 2015 18:48
-
-
Save Gergling/6001031 to your computer and use it in GitHub Desktop.
Shell script for generating new virtual hosts on Ubuntu based on old vhosts as a template. usage: bash newvhost [name old vhost] [name new vhost]
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 | |
SITES_AVAILABLE=/etc/apache2/sites-available/ | |
TEMPLATE=$SITES_AVAILABLE$1 | |
NEWVHOST=$SITES_AVAILABLE$2 | |
echo Copying template $TEMPLATE as new virtual host file. | |
sudo cp $TEMPLATE $NEWVHOST | |
echo Enabling new virtual host. | |
sudo a2ensite $2 | |
echo Running editor for new virtual host $NEWVHOST. | |
sudo scite $NEWVHOST | |
echo Running editor for new virtual host /etc/hosts. | |
sudo scite /etc/hosts | |
echo Restarting apache. | |
sudo service apache2 reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment