LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-08-2009, 12:45 PM   #1
raisinlove
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
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
 
Old 06-08-2009, 12:50 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
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.
 
Old 06-08-2009, 12:50 PM   #3
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
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.
 
Old 06-08-2009, 01:24 PM   #4
pliqui
Member
 
Registered: Feb 2007
Location: Caracas, Venezuela
Distribution: Debian x64
Posts: 156

Rep: Reputation: 17
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
 
Old 06-08-2009, 01:39 PM   #5
raisinlove
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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 View Post
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.
 
  


Reply

Tags
apache2, hosting, modrewrite, virtual


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't ping hosts outside local network arunksit Linux - Networking 2 04-07-2009 11:34 AM
LXer: Testing Network Ports LXer Syndicated Linux News 0 04-05-2009 03:33 AM
hosts conf. file - how to enable subdomains for testing? rotten_yellow Linux - Server 1 06-14-2008 11:48 PM
Web server in local network serving to internet librano Linux - Networking 1 04-25-2006 02:58 PM
my web server can't be reached by local network tiang_ono Linux - Software 4 07-14-2005 08:02 PM


All times are GMT -5. The time now is 08:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration