If you’re just a little bit like me, then you’ll love working with only a single active VirtualHost on apache2. Since switching from one server to another needs a lot of Linux terminal commands, I’ve built a small bash script that will hopefully ease the process.

 

The script  that changes the active VirtualHost of an apache2 web server simply lists all available hosts from /etc/apache2/sites-avaliable/ and then politely asks you to pick the one you want to activate.

 

Then it removes all symbolic links from /etc/apache2/sites-enabled/ and enables the VirtualHost you so badly want.
But, enough talk. Here are the ‘echos’ and ‘sudos’ that will make your life easier: