Test several websites on your computer at once
After watching several videos from last week's DrupalCon I had an itch to try out Drupal 7 for myself. The problem was I already had a site I was testing on my laptop. I could've downloaded it to my test server, but I've been testing alot lately at coffee shops with spotty wifi, so I decided I'd add some entries to my hosts file instead and write up a quick How-to.
(pre-requisites: You must have apache, php and mysql already running on your workstation. On ubuntu this is as simple as opening synaptic and searching for each of these packages and installing them: apache2, php5, mysql.)
3. restart apache
Multiple development websites in 3 steps.
1. Edit your hosts file. On Linux this is located at /etc/hosts. On Windows machines (XP, Vista, Windows 7) it is located at %SystemRoot%\system32\drivers\etc\hosts. On Mac OS X, its located in: /private/etc/hosts add a new entry for each website you want to test (don't worry you can add more later): 127.0.0.1 d7 127.0.0.1 d6 in this case I added two entries: one to test drupal 6, and a second to test drupal 7. To check that everything is working, open up a teriminal and ping d7 you should see something like this:2. Edit your Apache config file Add a$ ping d7 PING d7 (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.044 ms 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.047 ms 64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.051 ms 64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.055 ms
<VirtualHost *:80>
ServerName d7
DocumentRoot /home/bart/Public/drupal-7.x-dev
</VirtualHost>
<VirtualHost *:80>
ServerName d6
DocumentRoot /home/bart/Public/drupal-6.16
</VirtualHost>
$sudo apache2ctl restartNow you're ready to test the websites by opening up the URLs: http://d7 and http://d6 in a browser. As a bonus: go check out the DrupalCon2010 screencasts at archive.org.
Published
26 April 2010