Wednesday, April 14, 2010

11:14 PM

Often times when people install WAMP [or LAMP] stacks on their machines, they’ll commonly use http://localhost/ to access their local server. I did so for years until I started working with dynamic sub domains and needed to use something other than localhost to access my server. [or,] is a special domain as defined in RFC 2606 used for, you guessed it, examples. These domains will never be available to the public, so there’s no need to worry about not being able to access the actual site in the future.
Setting this up involves three main parts:
  1. Set up a static IP on your machine.
  2. Configuring Apache.
  3. Editing your host file.

Set up your static IP
There’s really no need to go into this. There are a ton of sites out there to help you set up your static IP:
– Windows
– Appletosh
– Linux

Apache Config
Everyone will have their httpd.conf file set up differently, so use this as an example of how to accomplish this. Keep in mind this file fragment should appear at the bottom of httpd.conf. I have also included my SSL layer here as well. It’s not important for most installations, but I included to show how to use it with

The main theory behind this is to set up everything under a VirtualHost:
Note: is my machine’s static IP, so be sure to replace it with YOUR static IP

# apache #
NameVirtualHost *:80
# Dir structure #
1.23:80 ServerName 192
Listen 192.168 ..168.1.23:80 <VirtualHost *:80>
/" # DocumentRoot "S:/apache/htdoc
DocumentRoot "S:/apache/htdoc ss/" # DocumentRoot "S:/apache/htdocs/"
ot "S:/apache/htdocs" ServerName www.example.
# DocumentRoot "S:/apache/htdocs/" # DocumentR ocom:80 </VirtualHost> # PMA # <VirtualHost *:80> DocumentRoot "S:/apache/htdocs/sql"
SSL # LoadModule ssl_module modul
ServerName </VirtualHost> # SSL -- Don't include this if you don't use es/ SSLRandomSeed startup builtin SSLRandomSeed connect builtin SSLMutex default SSLSessionCache none
Listen <VirtualHost *:443> DocumentRoot "S:/apache/htdocs/" # DocumentRoo tm/" # DocumentRoot "S:/apache/htdocs/" # DocumentRoot "S:/apache/htdocs/" # DocumentRoot "S:/apache/htdocs"
nf/pfs.key SetEnvIf User-Agent
ServerName SSLEngine On SSLCertificateFile S:/apache/conf/pfs.crt SSLCertificateKeyFile S:/apache/c o ".*MSIE.*" nokeepalive ssl-unclean-shutdown ErrorLog logs/ </VirtualHost>
Some directories are commented out, this allows me to run multiple sites on the server root. I just un-comment the site I want to work on, comment out the rest, restart the server and I’m good to go.

Host Files
Host files are like mini, stripped-down DNS servers that sit on your machine. This is where you tell your computer, “When I type in, I want it to go to my local server, not the internet”. Once again, this is something widely available on the net:

– Windows
– Appletosh
– Linux

Once you have your host files editable, add this to the bottom [don't over-write existing entries!] … also be sure to replace: YOUR static IP: localhost
Using your machine’s static IP over will allow other machines on your net work to connect to your server via … but you’ll need to edit those machine’s host files as well .. just use the same info from above on all your machines. Also make sure your firewall allows communication on Apache’s ports [80, 443].
You will more than likely have to restart your web browser or possibly your computer to get this to work.


Using a DNS server would eliminate the host file layer of this guide, but since I don’t use one, it’s not in this tutorial … but it would be ideal for larger companies or offices [after all, it's just me, myself and I in my company].

One thing I will openly admit about this tutorial is that I have very little experience configuring apache. everything you see here I found around the internet and played with it until it worked. With that said, if you are more knowledgeable with apache config and have something to add, PLEASE DO SO!