Apache - Name virtual host
Here's a question for all of you apache experts out there:
I installed Mandrake 8.2, set up mysql & php. I changed the document root and default document (index.php) for apache. Everything worked just fine. Everything was fine until I tried to set up apache to use name based virtual hosts. That's when everything went haywire. When I try to access ** ANYTHING ** on the web server, whether it be a document, image, etc I get a 500 server error. I do know that apache is reading the file to an extent, because the server error reports the correct serveradmin email address. Apache doesn't complain when it starts. I know sometimes if you have errors (especially in httpd.conf) it will report them and refuse to start. Not the case here. Can anyone tell me what is going on? I know I'm posting a lot of questions, but I'm just getting some of the cool features of linux figured out (samba, apache, mysql, etc.). I appreciate any help I can get. (thanks in advance). This is my /etc/httpd/conf/vhosts/Vhosts.conf: ################# Vhosts.conf #This is where we store the VirtualHosts configuration. # #This is needed for Frontpage support Port 80 ServerRoot /etc/httpd ResourceConfig /dev/null AccessConfig /dev/null ################# IP-based Virtual Hosts #<VirtualHost 192.168.2.100> #User jmdault #Group jmdault #DocumentRoot /home/jmdault/public_html #ServerName test2.com #Setenv VLOG /home/jmdault/logs #ErrorLogs /home/jmdault/test2-error_log #RewriteEngine On #RewriteOptions inherit #</VirtualHost> ################# Named VirtualHosts NameVirtualHost 10.0.0.15 <VirtualHost *> ServerName domain1.com:80 ServerAdmin webmaster@domain1.com ServerPath / DocumentRoot /web </VirtualHost> <VirtualHost *> ServerName www.domain1.com:80 ServerAdmin webmaster@domain1.com ServerAlias www.domain1.com www.domain1long.com ServerPath /domain1 DocumentRoot /web/domain1 #RewriteOptions inherit #ErrorLog /web/logs/domain1_log </VirtualHost> <VirtualHost *> ServerName www.domain2.com:80 ServerAdmin webmaster@domain2.com ServerAlias www.domain2.com www.domain2long.com ServerPath /domain2 DocumentRoot /web/domain2 #RewriteOptions inherit #ErrorLog /web/logs/domain2_log </VirtualHost> <VirtualHost *> ServerName www.domain3.com:80 ServerAdmin webmaster@domain1.com ServerAlias *.domain3.com ServerPath /lovelessash DocumentRoot /web/domain3 #RewriteOptions inherit #ErrorLog /web/logs/domain3_log </VirtualHost> |
uncomment the error_log directive - this is a requirement of apache.
|
Doesn't work
Hey, I appreciate the help.
Unfortunately, that didn't work. I still get the error. Moreover, I can't figure out why the "please contact the system administrator at [email addr]" for domain2 lists the email from domain1. I uncommented all lines from my previous post and ensured that the log files existed where I pointed them to. Still no luck. I get 500 server errors. I did a 'httpd -S' and got the following: [Sun May 5 18:15:23 2002] [warn] _default_ VirtualHost overlap on port 80, the first has precedence [Sun May 5 18:15:23 2002] [warn] _default_ VirtualHost overlap on port 80, the first has precedence [Sun May 5 18:15:23 2002] [warn] NameVirtualHost 10.0.0.15:80 has no VirtualHosts VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 www.domain1.com (/etc/httpd/conf/vhosts/Vhosts.conf:53) *:80 www.domain2.com (/etc/httpd/conf/vhosts/Vhosts.conf:63) *:80 www.domain3.com (/etc/httpd/conf/vhosts/Vhosts.conf:73) I did a 'httpd -t' and got the first three lines of the above error. Everything else checked out okay (Syntax OK). What do I do now? I have no idea how to fix it. Thanks for your help, Jason |
I got it to work. The Document Root had to have a forward slash on the end, and the ServerPath had to be /domain1/, /domain2/, etc.
Apache is powerful if you know how to use it. I've learned a lot, but am only scraping the tip of the iceberg. Anyway.... |
Virtual Hosts
Hey,
I got the same error, and here is the information from httpd.conf (Fedora Core 1, other systems using Apache 2.0.x should be similar) Quote:
After changing what is shown in red, it works for me. |
#
#NameVirtualHost *:80## see below just ip no * NameVirtualHost your_machine_ip # # VirtualHost example: ## take a look at first virtualhost container <VirtualHost domain1.com:80> ServerName domain1.com bla.... bla.... </VirtualHost> <VirtualHost domain2.com:80> ServerName domain2.com bla.... bla.... </VirtualHost> cheers :) |
All times are GMT -5. The time now is 04:34 PM. |