(Semi-)Automatically rebuild Apache VHOST configuration (Handy Shell Scripts – part III – rba.sh)

Now that we have a Development Webserver, we may have a local DNS server running to use a local TLD on the localhost and we have SSL added to our setup, we have discarded VirtualHostX , there is one thing that needs manual labor; and we hate that! (don’t we?). Maintaining the Apache2 Virtual-Host Configuration file and – in case of a DNS-less setup – the hosts file. Now, we do this automated! (Read on!)

It’s quite a long script, not very, and certainly not complicated, but – if you are not into shell scripting – it might be overwhelming. Just download it and chmod 755 it, then change a few lines;

DPATH=/Development

Change this to the path to your development base directory.

TLDS="local"

Add to or change this line to specify your own tld’s (mine says: TLDS=”dev dv”)

MYEMAIL=your@email.com

Not very hard to understand the meaning of this one, ey?

PHDIR=public_html

My setup uses /Development/domain.dev/public_html/the_website_here as structure, but yours might not. Change this to whatever you call your public dir. Direct Admin uses public_html, Plesk uses httpdocs. Whatever makes your boat float, I guess.

NETMODE=IPv6

If you use VirtualHostX, you would not be looking at this script. But you might be using a local DNS server. If you do, set this to ‘NONE’. If you don’t, set this to either IPv4, IPv6 or BOTH. If you don’t know what to do, set it to IPv4.

Save the file, and you’re done. (Don’t forget the chmod 755!)

Run it like this;

Shell command./rba.sh
(Of course, use the correct path to the file, alias it, whatever makes you comfortable.)

Enjoy!, and don’t hesitate to contact me if you run into problems, or perhaps even improve on my work :)

Revisions:

November 2016: moved file to github as gist, see https://gist.github.com/rmpel/dda9f0286e1de426dfde62921570d081

August 2014: Updated rba.sh script for Apache 2.4 used in OSX 10.10 Yosemite

Author: Remon Pel

WebDeveloper though not WebDesigner

Leave a Reply

Your email address will not be published. Required fields are marked *