IPB

Welcome Guest ( Log In | Register )



Tags
localhost     domain name    
3 Pages V   1 2 3 >  
Reply to this topicStart new topic

How To Assign A Virtual Domain Name To Your Localhost.

, Assigning virtual domain names and websites to your localhost.


xpress
no avatar
XPRESSing the XPRESSion
*********
Group: [HOSTED]
Posts: 599
Joined: 16-August 08
From: X Universe
Member No.: 66,523
Spam Patrol
myCENT:1.87



Post #1 post Dec 7 2008, 01:24 AM
How to assign a virtual domain name to your localhost.



With the help of this tutorial you can assign a virtual domain name to your localhost. That is you can access your local website with your favourite name like http://mysite.web instead of http://localhost and also you can assign different virtual domain names to different local webistes.


Requirements:
1.This tutorial is for Windows. Linux users can also use this, please follow rvalkass's instructions.

2.Apache webserver installed. It would be nice if you have WAMP server. This tutorial is based on WAMP server. But it works on any Apache server with little changes.

Procedure:

part1:

1. First go to location "C:\WINDOWS\system32\drivers\etc" directory.(or where you installed windows). Then open "hosts" file with simple text editor like notepad.

2. You'll see the following code at the end of the file.
CODE
127.0.0.1      localhost


In the next line add your virtual domain name like the example shown below.
CODE
127.0.0.1       mysite.web              #this is virtual domain name.


3. Now save the hosts file. mysite.web is just an example. You can add anything like "mywebsite.local" and you can use any extension or no extension at all. You can simply add "mysite" also

4. Now test your virtual domain. Just type http://mysite.web You must see your wamp page or webservers defalut page. If not you did something wrong. Go through the tutorial carefully.

Note: Don't use any real domain name like trap17.com or your own domain name if you have any. If you did so, you cannot access the original remote site. This is because, 127.0.0.1 is loopback address, anything with that address will never leave your computer.

Part 2:
Now second part, assigning virtual domain name to your web site in your webserver.

1. Open your httpd.conf file with Notepad. Click on WAMP icon in the tray, go to Apache menu and select httpd.conf there. You can also open the file by manually go to conf folder in Apache folder.

2. Create a new folder mysite in your C directory. And create a new web page index.html. These are for testing purposes. If you have a local website, specify the full path of website in below code.

3. Now add the following code at the end of the httpd.conf file.
CODE
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
       ServerName localhost
       DocumentRoot "C:/wamp/www"            #this is default wamp root for websites
</VirtualHost>

<VirtualHost 127.0.0.1>
    ServerName mysite.web            #your virtual domain name
    DocumentRoot "C:/mysite"        #location of your site, no extenison needed
#the following are security settings, allow you to access directory outside the www directory
               <Directory C:/mysite>            #again location of your website
          Order Allow,Deny
          Allow from all
               </Directory>
</VirtualHost>

Save httpd.conf file. Restart your WAMP server. now type http://mysite.web. You'll see the index page of mysite.

Adding Another Virtual Domain and Website:

If you want another website, first add another virtual domain in hosts file as shown in part1.
And then copy and paste the following code at the end of httpd.conf file. Just change the virtual domain name, and locations of website.

CODE
<VirtualHost 127.0.0.1>
    ServerName mywebsite.web            #change this virtual domain name
    DocumentRoot "C:/mywebsite"            #location of your site, change this.
       <Directory C:/mywebsite>            #again location of your website, change this
                  Order Allow,Deny
                  Allow from all
       </Directory>
</VirtualHost>

You can add as many websites as you wish. Just repeat the above procedure.

IF you have any doubts about this tutorial, post them here.

This post has been edited by xpress: Dec 8 2008, 12:35 AM
Go to the top of the page
+Quote Post
rvalkass
no avatar
apt-get moo
****************
Group: [MODERATOR]
Posts: 2,711
Joined: 28-May 05
From: Devon, England
Member No.: 7,593
Spam Patrol
myCENT:54.70



Post #2 post Dec 7 2008, 10:50 AM
This can be applied to Linux users too actually smile.gif

The hosts file is located at /etc/hosts. The httpd.conf file varies between different distributions, but is often stored at /etc/apache2/httpd.conf. Other than those two changes, the tutorial can be followed in exactly the same way.
Go to the top of the page
+Quote Post
xpress
no avatar
XPRESSing the XPRESSion
*********
Group: [HOSTED]
Posts: 599
Joined: 16-August 08
From: X Universe
Member No.: 66,523
Spam Patrol
myCENT:1.87



Post #3 post Dec 7 2008, 11:03 AM
QUOTE (rvalkass @ Dec 7 2008, 04:20 PM) *
This can be applied to Linux users too actually smile.gif

The hosts file is located at /etc/hosts. The httpd.conf file varies between different distributions, but is often stored at /etc/apache2/httpd.conf. Other than those two changes, the tutorial can be followed in exactly the same way.

Thanks for the information. I don't use linux that much, so I've no idea about server configurations in Linux. smile.gif
So...now Linux users can also use this tutorial as well. biggrin.gif

What about adding virtual domain names in Linux like adding it to hosts file in Windows(redirecting the localhost)? Do you have any idea?
Go to the top of the page
+Quote Post
rvalkass
no avatar
apt-get moo
****************
Group: [MODERATOR]
Posts: 2,711
Joined: 28-May 05
From: Devon, England
Member No.: 7,593
Spam Patrol
myCENT:54.70



Post #4 post Dec 7 2008, 11:08 AM
QUOTE (xpress @ Dec 7 2008, 11:03 AM) *
What about adding virtual domain names in Linux like adding it to hosts file in Windows(redirecting the localhost)? Do you have any idea?


The hosts file on Linux works in exactly the same way as the hosts file on Windows, so I see no reason why you couldn't. For example, this is what mine looks like:

CODE
127.0.0.1       localhost
127.0.1.1       rob-laptop

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


As far as I know it is exactly the same as a Windows one, and works in the same way.
Go to the top of the page
+Quote Post
Lightning73
no avatar
Premium Member
********
Group: [HOSTED]
Posts: 176
Joined: 12-September 08
Member No.: 67,760
myCENT:31.48



Post #5 post Dec 7 2008, 01:34 PM
Looks nice, I looked for this when I just started developing web applications. But now I don't really see the use of this. As you're the only one who'll be able to use the virtual domain name. I just accepted localhost as the domain to use, and it's easy enough.

Correct me if I'm wrong, but even though this tutorial is great, the use of virtual domain names on localhost is useless. (I really hope I'm wrong, so I'll learn something biggrin.gif)
Go to the top of the page
+Quote Post
xpress
no avatar
XPRESSing the XPRESSion
*********
Group: [HOSTED]
Posts: 599
Joined: 16-August 08
From: X Universe
Member No.: 66,523
Spam Patrol
myCENT:1.87



Post #6 post Dec 7 2008, 01:59 PM
QUOTE (Lightning73 @ Dec 7 2008, 07:04 PM) *
Looks nice, I looked for this when I just started developing web applications. But now I don't really see the use of this. As you're the only one who'll be able to use the virtual domain name. I just accepted localhost as the domain to use, and it's easy enough.

Correct me if I'm wrong, but even though this tutorial is great, the use of virtual domain names on localhost is useless. (I really hope I'm wrong, so I'll learn something biggrin.gif)


Even though you don't get any great benefits with virtual domain name for localhost, they are quite handy when you have multiple websites on your localhost.

For example you have two webistes in your computer, one is your general site, lets call it mysite, and you're developing another website for mail applications mymail. When you want to access these sites you have to type
http://localhost/mysite, or http://localhost/mymail. But f you have these virutal domains you can directly call them http://mysite or like that. So....it is easy to access your site and also looks informative as well.

And also if you assign a good extension to them they'll look like real domain names. So you can feel them as a real domain name for local websites. tongue.gif

This post has been edited by xpress: Dec 7 2008, 02:02 PM
Go to the top of the page
+Quote Post
websey
no avatar
Member [Level 1]
****
Group: Members
Posts: 65
Joined: 1-December 08
Member No.: 73,985
myCENT:90.75



Post #7 post Dec 7 2008, 05:18 PM
Cheers express,

You always bring a good tut,

Also just one thing I use xampp is there much difference ????

Also juts one more thing how long does it take to get a *edit by jlhaslip* tut ok'd mine is taking forever and a day !

anyway nice tut

saves me typing /localhost/website all the time as i have 7 sites currently

Notice from jlhaslip:
Edit to remove questionable adjective
Go to the top of the page
+Quote Post
xpress
no avatar
XPRESSing the XPRESSion
*********
Group: [HOSTED]
Posts: 599
Joined: 16-August 08
From: X Universe
Member No.: 66,523
Spam Patrol
myCENT:1.87



Post #8 post Dec 8 2008, 12:46 AM
QUOTE (websey @ Dec 7 2008, 10:48 PM) *
Cheers express, You always bring a good tut, Also just one thing I use xampp is there much difference ????

Thanks websey...Not much difference there with XAMPP, the procedure is same, just locate your httpd.conf file and edit it as per instructions, thats it.
Go to the top of the page
+Quote Post
enhu
no avatar
Newbie [Level 3]
***
Group: Members
Posts: 48
Joined: 18-November 08
Member No.: 72,708
myCENT:40.06



Post #9 post Dec 8 2008, 04:29 AM
this really helps especially to me since i'm not good in typing. I named my site "mysite" very handy.
Go to the top of the page
+Quote Post
freeflashclocks
no avatar
Advanced Member
*******
Group: [HOSTED]
Posts: 131
Joined: 4-July 08
Member No.: 64,591
myCENT:94.81



Post #10 post Dec 9 2008, 05:36 PM
Usefull and very complete tutorial, i also found it simple and easy to read as well as to understand its content and purpose of the same.

I actually never wanted to do this, so i also did not wanted to learn how to do this too, but if i wanted, this would be the tutorial i would choosen to learn, so if in a near future i feel the need to do this steps, this is the best tutorial to have, thank you for your effors, it must have take you quite a while to build it.
Go to the top of the page
+Quote Post

3 Pages V   1 2 3 >
Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   6 Echo_of_thunder 1,289 26th March 2009 - 09:04 PM
Last post by: TheDisturbedOne
No new   19 dragonfang00 1,991 30th August 2009 - 12:10 PM
Last post by: The Simpleton
No New Posts   1 zip_mc 5,879 31st July 2004 - 03:16 PM
Last post by: OpaQue
No New Posts   3 t3h_m0nst3r 5,407 29th July 2004 - 09:25 PM
Last post by: t3h_m0nst3r
No New Posts   1 t3h_m0nst3r 4,220 30th July 2004 - 03:33 AM
Last post by: Thunder
No New Posts   1 Lal 5,660 4th August 2004 - 04:43 AM
Last post by: OpaQue
No new   41 bk2070 5,462 18th October 2009 - 08:30 PM
Last post by: bk2070
No New Posts   3 SSS 5,383 4th August 2004 - 04:58 AM
Last post by: OpaQue
No New Posts   3 icleric 5,972 4th August 2004 - 07:50 AM
Last post by: OpaQue
No New Posts   1 itasor 5,500 4th August 2004 - 08:08 AM
Last post by: OpaQue
No New Posts   1 khaz 4,404 4th August 2004 - 07:17 AM
Last post by: OpaQue
No New Posts   1 dask 3,925 4th August 2004 - 07:39 AM
Last post by: OpaQue
No New Posts   2 itasor 5,456 6th August 2004 - 05:24 PM
Last post by: OpaQue
No New Posts   2 dask 4,350 7th August 2004 - 05:42 AM
Last post by: chinfo
No New Posts   1 Donegal 3,563 9th August 2004 - 08:52 AM
Last post by: OpaQue


 



RSS Open Discussion Time is now: 8th November 2009 - 03:15 AM

Web Hosting Powered by ComputingHost.com.