|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#1
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 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [MODERATOR]
Posts: 2,711 Joined: 28-May 05 From: Devon, England Member No.: 7,593 ![]() myCENT:54.70 |
Post
#2
Dec 7 2008, 10:50 AM
This can be applied to Linux users too actually 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. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#3
Dec 7 2008, 11:03 AM
This can be applied to Linux users too actually 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. So...now Linux users can also use this tutorial as well. What about adding virtual domain names in Linux like adding it to hosts file in Windows(redirecting the localhost)? Do you have any idea? |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [MODERATOR]
Posts: 2,711 Joined: 28-May 05 From: Devon, England Member No.: 7,593 ![]() myCENT:54.70 |
Post
#4
Dec 7 2008, 11:08 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. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#5
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 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#6
Dec 7 2008, 01:59 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 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. This post has been edited by xpress: Dec 7 2008, 02:02 PM |
![]() ![]() ![]() ![]() |
Post
#7
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 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#8
Dec 8 2008, 12:46 AM
|
![]() ![]() ![]() |
Post
#9
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.
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Post
#10
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. |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
6 | Echo_of_thunder | 1,289 | 26th March 2009 - 09:04 PM Last post by: TheDisturbedOne |
|||
![]() |
19 | dragonfang00 | 1,991 | 30th August 2009 - 12:10 PM Last post by: The Simpleton |
|||
![]() |
1 | zip_mc | 5,879 | 31st July 2004 - 03:16 PM Last post by: OpaQue |
|||
![]() |
3 | t3h_m0nst3r | 5,407 | 29th July 2004 - 09:25 PM Last post by: t3h_m0nst3r |
|||
![]() |
1 | t3h_m0nst3r | 4,220 | 30th July 2004 - 03:33 AM Last post by: Thunder |
|||
![]() |
1 | Lal | 5,660 | 4th August 2004 - 04:43 AM Last post by: OpaQue |
|||
![]() |
41 | bk2070 | 5,462 | 18th October 2009 - 08:30 PM Last post by: bk2070 |
|||
![]() |
3 | SSS | 5,383 | 4th August 2004 - 04:58 AM Last post by: OpaQue |
|||
![]() |
3 | icleric | 5,972 | 4th August 2004 - 07:50 AM Last post by: OpaQue |
|||
![]() |
1 | itasor | 5,500 | 4th August 2004 - 08:08 AM Last post by: OpaQue |
|||
![]() |
1 | khaz | 4,404 | 4th August 2004 - 07:17 AM Last post by: OpaQue |
|||
![]() |
1 | dask | 3,925 | 4th August 2004 - 07:39 AM Last post by: OpaQue |
|||
![]() |
2 | itasor | 5,456 | 6th August 2004 - 05:24 PM Last post by: OpaQue |
|||
![]() |
2 | dask | 4,350 | 7th August 2004 - 05:42 AM Last post by: chinfo |
|||
![]() |
1 | Donegal | 3,563 | 9th August 2004 - 08:52 AM Last post by: OpaQue |
|||
|
Open Discussion | Time is now: 8th November 2009 - 03:15 AM |
Web Hosting Powered by ComputingHost.com.