Got a new web project? Request a quote

bash

Automatically setup a vhost

Setting up an apache vhost is a boring task. This is why most of the times, I use the h*tp://localhost/project subdirectory for my development work.

This is perfectly ok for most cases, however in some occasions you may wish to create a virtual host so that your project is accessible like: h*tp://project

To do this, you need to create a file in the the sites-available directory of your apache instance, set up a link in the sites-enabled directory, add an entry in the /etc/hosts file and finally restart apache.
Too much work. Fortunately we can automate it:

Create a template file (you can copy from an old project) in the sites-available directory. Replace every reference of your old project name and directory name with 'TEMPLATE'. Name this template file also 'TEMPLATE'
Then, create a shell script and add the following lines:

#!/bin/sh