Skip to content

Instantly share code, notes, and snippets.

@Gergling
Last active December 19, 2015 18:48
Show Gist options
  • Save Gergling/6001031 to your computer and use it in GitHub Desktop.
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]
#!/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