| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-08-2009, 12:45 PM
|
#1
|
|
LQ Newbie
Registered: Jun 2009
Posts: 2
Rep:
|
Testing web server on local network with ports... how to use with hosts file?
Hey all,
I have just setup a local webserver on a (virtual machine) Ubuntu box.
I have successfully set up multiple sites via virtual hosting using the server's IP with a different port number for each website.
Since this is only intended for local testing, it wasn't necessairy to access these via the web, so I went ahead and added each adress to my local Windows HOSTS file so I could test the websites with their actual domain names.
I found out you can't use port numbers in the HOSTS file... So what are the alternatives?
Last edited by raisinlove; 06-08-2009 at 12:47 PM.
Reason: activate instant email notification
|
|
|
|
06-08-2009, 12:50 PM
|
#2
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,711
|
using different port numbers totally undermines the point of virtual hosts. the whole point that virtual hosts exist is to be able to serve multiple sites on ONE port, i.e port 80 (and 443). Reconfigure your apache config to not use multiple ports.
And please don't think that not being able to use port numbers in your host file is a short coming of anything at all. It makes no sense at all to associate a domain name with a port, just totally illogical.
|
|
|
|
06-08-2009, 12:50 PM
|
#3
|
|
Senior Member
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154
Rep:
|
you don't need to assign a different port to discriminate virtual hosts -- they can all be listening on port 80.
But put the domains in your hosts file pointing to the ubuntu box's IP. Then from your browser (on the machine with the modified hosts file) try to browse to the domain.
if it doesn't pull up, flush your cache and try again. also: ping the domain to verify your hosts file is correct.
|
|
|
|
06-08-2009, 01:24 PM
|
#4
|
|
Member
Registered: Feb 2007
Location: Caracas, Venezuela
Distribution: Debian x64
Posts: 152
Rep:
|
Indeed, like secesh and acid_kewpie said, you don't need to configure every site with a different port, i will paste my httpd.conf and see that all the sites have the same port.
Code:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName desabancodevenezuela.com
ServerAlias www.desabancodevenezuela.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/desabancodevenezuela.com
# Logfiles
ErrorLog /var/www/desabancodevenezuela.com/logs/error.log
CustomLog /var/www/desabancodevenezuela.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName munin
ServerAlias munin
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/www/munin
# Logfiles
ErrorLog /var/www/munin/logs/error.log
CustomLog /var/www/munin/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName sep
ServerAlias sep
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/sep
# Logfiles
ErrorLog /var/www/munin/logs/error.log
CustomLog /var/www/munin/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName webalizer
ServerAlias webalizer
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/www/webalizer
# Logfiles
ErrorLog /var/www/webalizer/logs/error.log
CustomLog /var/www/webalizer/logs/access.log combined
</VirtualHost>
And you can see on my windows machine i just configure the host to same ip
Code:
120.48.28.32 desabancodevenezuela
120.48.28.32 munin
120.48.28.32 cacti
120.48.28.32 sep
120.48.28.32 webalizer
|
|
|
|
06-08-2009, 01:39 PM
|
#5
|
|
LQ Newbie
Registered: Jun 2009
Posts: 2
Original Poster
Rep:
|
Thanks guys,
the logic behind my use of ports was simply that I had tried doing this way before and it had failed. Finding that it worked with the ports led me to believe that I fixed my problem this way, when it was actually something unrelated that caused my previous config not to recognized multiple websites. In short, I went back to the basic way as suggested above and it works great.
Quote:
Originally Posted by acid_kewpie
And please don't think that not being able to use port numbers in your host file is a short coming of anything at all. It makes no sense at all to associate a domain name with a port, just totally illogical.
|
Nah, I just thought it would be ok since I'm only accessing the sites localy. But I realize now it was overkill.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:57 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|