Setting up your localhost as

Posted on June 14, 2008. Filed under: Apache | Tags: , , , , , , , |

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:


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 #

    <VirtualHost *:80>
        DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs"

# PMA #
    <VirtualHost *:80>
        DocumentRoot "S:/apache/htdocs/sql"

# SSL -- Don't include this if you don't use SSL #
    LoadModule ssl_module modules/
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    SSLMutex default
    SSLSessionCache none


    <VirtualHost *:443>
        DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs/"
#       DocumentRoot "S:/apache/htdocs"

        SSLEngine On
        SSLCertificateFile S:/apache/conf/pfs.crt
        SSLCertificateKeyFile S:/apache/conf/pfs.key
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
        ErrorLog logs/

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:


Once you have your host files editable, add this to the bottom [don’t over-write existing entries!] … also be sure to replace: with 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! :-)


Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

5 Responses to “Setting up your localhost as”

RSS Feed for Adventures in PHP / DHTML / CSS and MySQL Comments RSS Feed

If you want to save your time, use XAMPP software bundle or WITSuite EasyInstaller (WITSuite installation video: It is most simple way to install Apache, PHP, MySQL on Windows.

I’m not necessarily looking for the easiest way to install a WAMP stack, my main goal is to mimic the servers the sites will eventually go on as much as possible. I used to use WAMP packages and they never fit my needs and most if not all WAMP stacks I’ve seen lack ImageMagick and memcached and are installed on one machine, instead of multiple [Web server on one, MySQL server on another].

Thanks for the heads up, though :-)

[…] – bookmarked by 3 members originally found by ov69 on 2008-07-31 Setting up your localhost as – bookmarked by […]

Very interesting, didn’t knew we can use as our localhost, thanks for letting me know.

Great information and direction for a standard! Thanks and greetings!

Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: