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> |
Need more information, what is inside your <VirtualHost ...> directive
Are you behind a firewall? what is your local ip address? |
Quote:
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> |
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> |
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. |
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> |
All times are GMT -5. The time now is 11:25 AM. |