Setup a development version of website?

Hi, I am thinking to currently setup a development version of the website.
That way I can keep working and testing things while at the same time have the website live and unaffected. I was told to just make a new virtual host and then give it the url name and then point it to a directory inside your current website in a folder called dev.

I want to do it painlessly. I mean in a way where I don't have to manually change the directory path. I do use both a direct path and a url path in a few files.

Any ideas?
 
Best idea: restructure your code. Whatever language you are using, it should be possible to make the code transportable to other drives / hosts / file systems.

I have my dev | test | production systems all pulling from a version control system (devel/mercurial). Published code is identical on each.

In one module a few lines of code ensure the appropriate differences between the hosts | virtual hosts are accounted for. Test for the hostname or some other unique, machine centric, attribute - then your code can adjust configuration details accordingly, automatically.

Pseudo-code:

Code:
live_host = "www.mycompany.com"
dev_host = "froggy.mycompany.com"
test_host = "staging.mycompany.com"

configuration = (
    http_address = None
    https_address = None
    static_path = "path/to/static"
    raise_exceptions = True
    is_live_host = False
    # and more...
)

if gethostbyname() == live_host:
    configuration.raise_exceptions = False
    configuration.is_live_host = True
    static_path = "/www/thisapp/static"

if gethostbyname() == dev_host:
    static_path = "~/apps/current/static"

... and so on.

Instead of hard-coding paths throughout your code base, put them in a configuration file.
 
Back
Top