LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-06-2005, 10:42 AM   #1
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Rep: Reputation: 30
Question Help with apache virtual hosts (and iptables too)


Hi there,

I've got apache installed and all is working well, but I want to have multiple sites available on my machine.

From reading the manual I could add

<VirtualHost *:80>
ServerName test.localhost
DocumentRoot "/home/web/"
</VirtualHost>

<VirtualHost *:80>
ServerName test2.localhost
DocumentRoot "/home/web2/"
</VirtualHost>

and if I then type http://test.localhost into my webbrowser I should get the index.html residing in /home/web

but instead I get a www.test.localhost could not be found error. Could someone please tell me what I have done wrong?

Finally if someone knows of a simple tutorial so I can set up a firewall on my machine using iptables that would be great (all the ones I can find seem to assume you're some sort of network guru )

Thanks for the help!
 
Old 12-06-2005, 01:11 PM   #2
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
The problem will probably go away if you add some ServerAlias directives to the virtual host definitions. For example:

<VirtualHost *:80>
ServerName test.localhost
ServerAlias www.test.localhost
ServerAlias *.test.localhost
DocumentRoot "/home/web/"
</VirtualHost>

The *.test.localhost really should catch everything, but you traditionally add any alias you know is actually in use.

See: http://httpd.apache.org/docs/2.0/mod...ml#serveralias

And: http://www.dyndns.com/support/kb/arc...th_apache.html
 
Old 12-06-2005, 01:57 PM   #3
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Original Poster
Rep: Reputation: 30
Thanks for the info, is still doesn't seem to be working though

<VirtualHost *:80>
ServerName test.localhost
DocumentRoot "/home/web/"
ServerAlias "www.test.localhost"
ServerAlias "*.test.localhost"
</VirtualHost>
 
Old 12-06-2005, 02:32 PM   #4
sandwhale
LQ Newbie
 
Registered: Nov 2004
Location: DFW Texas
Distribution: Debian Sarge
Posts: 20

Rep: Reputation: 0
I don't think you need the quotes - not sure if that would jack this up or not though
 
Old 12-06-2005, 03:20 PM   #5
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
I agree. No quotes.
 
Old 12-07-2005, 03:35 AM   #6
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Original Poster
Rep: Reputation: 30
Still no joy without quotes anywhere

It's apache 1.3x by the way - I don't think that makes any difference though
 
Old 12-07-2005, 09:50 AM   #7
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
The problem may be related to ServerName and ServerAlias looking for Fully Qualified Domain Names.

Looking at a local server running virtual hosts, http://localhost gives the default virtual host, whereas http://test.localhost results in “www.test.locahost not found”. Likewise, “ping localhost” works fine and ping “test.localhost” fails.

After adding test.localhost to /etc/hosts, test.localhost works fine in Apache and ping.

/etc/hosts addition:

127.0.0.1 test.localhost

You will probably still need to have “ServerAlias *...localhost” in the definitions.
 
Old 12-07-2005, 11:24 AM   #8
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Original Poster
Rep: Reputation: 30
That solves the problem, thanks very much!
 
Old 12-07-2005, 11:46 AM   #9
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
When I went back and reread the Apache documentation on the ServerName directive, FQDN jumped off the screen at me. Sometimes it’s the really obvious stuff that’s hard to figure out.

Glad everything worked out.
 
  


Reply



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
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
Apache Virtual Hosts dienerk Linux - General 15 10-16-2004 12:46 AM
Apache Virtual Hosts gbg Linux - Software 4 10-02-2003 08:35 AM
Apache Virtual Hosts (again) scatcat Linux - General 1 10-17-2002 09:51 AM
Apache: Virtual hosts pk21 Linux - Software 15 10-08-2002 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration