How To: Run Multiple Domains On A Local Computer

Jauhari

10 comments

Link

During web development, sometime you (I always) need to test with a domain name, whether inside local computer or online. This post will tell you how to run multiple domain on your local PC, without setting up a DNS server. I am using Apache 2.0.53.

Case: You want to develop a website for your-domain.com and need to test it online under certain domain name.

Solution:

[1] Create a local domain name

To differ between online and local domain, you need to create a local domain name (sub domain is okay), i.e: local.yourdomain.com

[2] Edit your hosts file

In Windows XP, the “hosts” file can be found at “C:\WINDOWS\system32\drivers\etc”. Put your local domain/subdomain there with the following order:

127.0.0.1 local.yourdomain.com

Hosts File

[3] Add a Virtual Host into your apache configuration file (httpd.conf)

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot “D:\path\to\your\web_directory”
ServerName local.yourdomain.com
ErrorLog logs/local.yourdomain-error_log
CustomLog logs/local.yourdomain-access_log common
</VirtualHost>

httpd.conf

[4] Done.

Point your web browser to http://local.yourdomain.com. I have a result like this.

Result

From now on, you can run multiple domain on your local PC, without the need to install DNS server.

Questions are welcome. Just leave it here and I am ready to help you.

Share:

Related Post

10 responses to “How To: Run Multiple Domains On A Local Computer”

  1. Orang Indonesia Avatar

    Finally I found here, thank you mas.

    1. Arief Fajar Nursyamsu Avatar

      It is great to know that this post is useful for you.
      Thanks for visiting.

  2. […] Membuat virtual host dengan domain sama persis dengan yang akan digunakan. Tetapi akan menimbulkan masalah kalau saya akan mengakses web yang sebenarnya (versi lama), walaupun bisa dinyalakan atau dimatikan dengan mengedit file hosts. […]

  3. Google Local Searches Avatar

    thanks for the step-by-step guide. this would help a lot especially to those who are just starting. more power to your site.

  4. Dona Avatar

    Hi, I hope you can answer my question about How can i manage more than one site using WordPress? do i have to download wp more than once? I already downloaded it through my Cpanel once and now i need to work on my other domains.
    thank you

    1. Jauhari Avatar

      You can added multiple author on your WordPress or installed WordPress MU

  5. Leonardo Martinez Avatar

    Thanks, it worked like a charm. For those of you wondering, I even entered a standard domain name like xyz.com and the computer is recognizing it as a locally.

  6. vietnam idol Avatar

    Oh ! thanks you very much ! I’m creating a local domain name . but I am not sure ! I hope I read a lot of posting about this topic . Thanks again .

  7. Divya Avatar

    do we a static ip to assig our subtomain to our local system

    1. Jauhari Avatar

      The Static IP is 127.0.0.1

Leave a Comment