Simple Staging

Here's yet another idea for setting up your computer to stage a bunch of websites. I run servers on 127.0.0.1 and name all the websites so they end in ".lo" like "test.lo" and "id.lo". I put these into /etc/hosts:

127.0.0.1 test.lo
127.0.0.1 id.lo

Then, create the typical config files (in /etc/apache2/sites-enabled).

Last, create an index.php in /var/www that reads /etc/hosts and generates a page of links to these staging sites:

<?php
$f = file("/etc/hosts");
foreach($f as $line)
        if (preg_match("/\b([\w-]+?\\.lo)/", $line, $p))
                print "<p><a href='http://$p[1]'>$p[1]</a></p>\n";

.