Friday, February 22, 2013

How to Create Fake Domain Name on Localhost

 The purpose of this tutorial is to create fake domain name on localhost, i.e. you are running your local website online:

1. Create folder which will serve as your Web applications directory. You can place Web applications as many as you want in this folder. In my case:

C:/workspace/www

2. Suppose I want to develop my Web application or website whose domain is j2technologies.com, then I'll create folder inside the above-created working directory and name it:

j2technologies.com

Hence, C:/workspace/www/j2technologies.com.



3. I will now create 2 new folders inside j2technologies.com folder:

conf
public_html

conf is where configuration will be placed and public_html is where web documents will be placed. Index file, either index.html or index.php, should be on top of public_html.

Hence, C:/workspace/www/j2technologies.com/conf and C:/workspace/www/j2technologies.com/public_html.

4. You should place or extract (like joomla, wordpress, phpbb, drupal, etc) your web files on top of public_html, i.e. index file should be in public_html.

5. Open your favorite text editor. I suggest Notepad. Type in the following and save as conf.conf (not .txt) inside folder conf:

<VirtualHost *:80>   
    ServerAdmin admin@j2technologies.com
    DocumentRoot "C:/workspace/www/j2technologies.com/public_html"
    ServerName j2technologies.com
    ServerAlias www.j2technologies.com
    ErrorLog "logs/j2technologies.com-error.log"
    CustomLog "logs/j2technologies.com-access.log" common
    <Directory "C:/workspace/www/j2technologies.com/public_html">
        Order Deny,Allow
        Allow from all
    </Directory>
</VirtualHost>

6. Open Apache httpd.conf configuration. At the last line add the following:

NameVirtualHost *:80

7. Then add also the following:

Include "C:/workspace/www/j2technologies.com/conf/conf.conf"

Save and close Apache httpd.conf configuration.

8. Open hosts file in Notepad. hosts file is located at C:\Windows\System32\drivers\etc. Yes, it does not have extension. At the last line, type in the following:

127.0.0.1    j2technologies.com
127.0.0.1    www.j2technologies.com

If this file is edited for the first time, you may save it first in Desktop with the same name without extension, hosts. Then copy this to C:\Windows\System32\drivers\etc to overwrite existing hosts file.

8. Restart Apache. You should be able to open your site with www.j2technologies.com or j2technologies.com.

Download PDF file.

Thanks. Suggestions and comments are highly appreciated.

No comments:

Post a Comment