LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-12-2003, 07:47 PM   #1
rajanr
LQ Newbie
 
Registered: Jul 2003
Location: Vancouver, BC - Canada
Distribution: Red Hat 9
Posts: 12

Rep: Reputation: 0
Apache: Virtual Host Config question


I have 2 domain names (myvent.com & pmtoolkit.com) that I am trying to set up on my Apache 2.0 server which is running on a Red Hat Linux 9 installation.

The DNS servers of my ISP point both domain names to the static IP address of my Linux server - 208.181.164.164

Here's what I want to do:

If a user enters http://208.181.164.164 I want the server to serve an index.html page from the DocumentRoot which is "/var/www/html".

If a user enter http://www.myvent.com I want the server to serve a page from the myvent.com VirtualHost DocumentRoot which is "/var/www/html/vent/phpBB"

If a user enters http://www.pmtoolkit.com I want the server to serve a page from the pmtoolkit.com VirtualHost DocumentRoot which is "/var/www/html/pmtoolkit"

Here's what happens:

If a user enters http://www.myvent.com, a page from this VirtualHost's DocumentRoot is served.

If a user enters http://www.pmtoolkit.com, a page from this VirtualHost's DocumentRoot is served.

If a user on the local LAN enters http://192.168.50.1 (this is the local IP address of the linux server), a page from the DocumentRoot "/var/www/html" is served.

However, if a user enters http://208.181.164.164, a page from the VirtualHost pmtoolkit.com's DocumentRoot ("/var/www/html/vent/phpBB") is served instead of a page from the DocumentRoot "/var/www/html"

Could someone please help me solve this.

I have listed part of my httpd.conf file below:

Thanks,

--Rajan


NameVirtualHost 208.181.164.164


# Where do we put the lock and pif files?
LockFile "/var/lock/httpd.lock"
CoreDumpDirectory "/etc/httpd"

# Defaults for virtual hosts

# Logs

#
# Virtual hosts
#

# Virtual host Default Virtual Host
<VirtualHost *>

ServerSignature email

DirectoryIndex index.php index.html index.htm index.shtml

LogLevel warn
HostNameLookups off

</VirtualHost>

# Virtual host myvent.com
<VirtualHost myvent.com>
DocumentRoot /var/www/html/vent/phpBB

ServerAdmin rajan@myvent.com
ServerName www.myvent.com
ErrorLog /var/log/httpd/myvent/myvent_error_log
CustomLog /var/log/httpd/myvent/myvent_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>


# Virtual host pmtoolkit.com
<VirtualHost pmtoolkit.com>
DocumentRoot /var/www/html/pmtoolkit

ServerAdmin rajan@pmtoolkit.com
ServerName www.pmtoolkit.com
ErrorLog /var/log/httpd/pmtoolkit/pmt_error_log
CustomLog /var/log/httpd/pmtoolkit/pmt_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>

Last edited by rajanr; 08-12-2003 at 10:13 PM.
 
Old 08-12-2003, 09:20 PM   #2
Cooner
Member
 
Registered: Jul 2003
Location: Hastings, MN. USA
Distribution: Ubuntu 10.xx
Posts: 109

Rep: Reputation: 15
Need more information, what is inside your <VirtualHost ...> directive
Are you behind a firewall?
what is your local ip address?

Last edited by Cooner; 08-12-2003 at 09:31 PM.
 
Old 08-12-2003, 10:28 PM   #3
rajanr
LQ Newbie
 
Registered: Jul 2003
Location: Vancouver, BC - Canada
Distribution: Red Hat 9
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Cooner
Need more information, what is inside your <VirtualHost ...> directive
Are you behind a firewall?
what is your local ip address?
Actually, I think I've mentioned this information in my earlier post or maybe I am not sure what you might be refering to (note: I am a newbie at Linux). I've copied the same info below:

And, the local IP of the machine on which the apache server is running is: 192.168.50.1.

There's no firewall at present but I'll try to set it up after I get this resolved.


Here's part of the httpd.conf file:

NameVirtualHost 208.181.164.164


# Where do we put the lock and pif files?
LockFile "/var/lock/httpd.lock"
CoreDumpDirectory "/etc/httpd"

# Defaults for virtual hosts

# Logs

#
# Virtual hosts
#

# Virtual host Default Virtual Host
<VirtualHost *>

ServerSignature email

DirectoryIndex index.php index.html index.htm index.shtml

LogLevel warn
HostNameLookups off

</VirtualHost>

# Virtual host myvent.com
<VirtualHost myvent.com>
DocumentRoot /var/www/html/vent/phpBB

ServerAdmin rajan@myvent.com
ServerName www.myvent.com
ErrorLog /var/log/httpd/myvent/myvent_error_log
CustomLog /var/log/httpd/myvent/myvent_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>


# Virtual host pmtoolkit.com
<VirtualHost pmtoolkit.com>
DocumentRoot /var/www/html/pmtoolkit

ServerAdmin rajan@pmtoolkit.com
ServerName www.pmtoolkit.com
ErrorLog /var/log/httpd/pmtoolkit/pmt_error_log
CustomLog /var/log/httpd/pmtoolkit/pmt_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>
 
Old 08-13-2003, 08:00 AM   #4
Cooner
Member
 
Registered: Jul 2003
Location: Hastings, MN. USA
Distribution: Ubuntu 10.xx
Posts: 109

Rep: Reputation: 15
Well this works for me

NameVirtualHost 192.168.1.16

<VirtualHost 192.168.1.16>
UseCanonicalName off
ServerAdmin me@myworld.com
DocumentRoot /var/www/html
ServerName "ACTUAL SERVER NAME"
ErrorLog /var/log/apache/apache-errorlog
CustomLog /var/log/apache/apache-access_log common
</VirtualHost>
<VirtualHost 192.168.1.16>
UseCanonicalName off
ServerAdmin me@myworld.com
DocumentRoot /var/www/html/test1
ServerName test1.gotdns.com
ErrorLog /var/log/apache/test1.gotdns.com-errorlog
CustomLog /var/log/apache/test1.gotdns.com-access_log common
</VirtualHost>
<VirtualHost 192.168.1.16>
UseCanonicalName off
ServerAdmin me@myworld.com
DocumentRoot /var/www/html/test2
ServerName test2.gotdns.com
ErrorLog /var/log/apache/test2.gotdns.com-errorlog
CustomLog /var/log/apache/test2.gotdns.com-access_log common
</VirtualHost>
 
Old 08-30-2003, 12:15 PM   #5
rebel
LQ Newbie
 
Registered: Aug 2003
Distribution: CentOS
Posts: 24

Rep: Reputation: 15
That's it. The solution is to configure in your httpd.conf

NameVirtualHost 192.168.50.1

instead of

NameVirtualHost 208.181.164.164

and when you type in the domain names they will lead to the different directories (set via DocumentRoot directive) correctly.
 
Old 08-30-2003, 12:41 PM   #6
rajanr
LQ Newbie
 
Registered: Jul 2003
Location: Vancouver, BC - Canada
Distribution: Red Hat 9
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, although here's what I did AND IT WORKS! (I should have posted this earlier.)

# Virtual host Default Virtual Host
<VirtualHost *>

ServerSignature email

DirectoryIndex index.php index.html index.htm index.shtml

LogLevel warn
HostNameLookups off

</VirtualHost>

# Virtual host 208.181.164.164
<VirtualHost 208.181.164.164>
DocumentRoot /var/www/html

ServerAdmin rajan@myvent.com
ServerName www.myvent.com
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log common

<Directory "/">
AllowOverride none

</Directory>


# Virtual host myvent.com
<VirtualHost myvent.com>
DocumentRoot /var/www/html/vent/phpBB

ServerAdmin rajan@myvent.com
ServerName www.myvent.com
ErrorLog /var/log/httpd/myvent/myvent_error_log
CustomLog /var/log/httpd/myvent/myvent_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>


# Virtual host pmtoolkit.com
<VirtualHost pmtoolkit.com>
DocumentRoot /var/www/html/pmtoolkit

ServerAdmin rajan@pmtoolkit.com
ServerName www.pmtoolkit.com
ErrorLog /var/log/httpd/pmtoolkit/pmt_error_log
CustomLog /var/log/httpd/pmtoolkit/pmt_access_log common

<Directory "/">
AllowOverride none

</Directory>

</VirtualHost>
 
  


Reply


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
Apache named virtual host config darthtux Linux - Software 8 04-19-2005 02:38 AM
Apache virtual host question fredws Linux - Software 1 01-22-2004 12:12 PM
Virtual host config won't work klintonray Linux - Networking 18 08-19-2003 02:53 PM
Major Virtual Host Config Issues klintonray Linux - Software 2 08-07-2003 07:20 PM
Apache Virtual Host Question fed007 Linux - Networking 6 12-02-2002 04:46 AM


All times are GMT -5. The time now is 04:36 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