LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Apache - Name virtual host (https://www.linuxquestions.org/questions/linux-networking-3/apache-name-virtual-host-20190/)

tisource 05-04-2002 11:10 AM

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>

Dave Campbell 05-05-2002 06:21 PM

uncomment the error_log directive - this is a requirement of apache.

tisource 05-05-2002 08:08 PM

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

tisource 05-08-2002 05:14 PM

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....

deoren 03-11-2004 11:03 AM

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:

### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>


After changing what is shown in red, it works for me.

routers 03-03-2006 02:52 AM

#
#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.