LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-04-2002, 11:10 AM   #1
tisource
Member
 
Registered: Feb 2002
Posts: 322

Rep: Reputation: 30
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>
 
Old 05-05-2002, 06:21 PM   #2
Dave Campbell
Member
 
Registered: Dec 2001
Location: London
Distribution: Redhat 6.2
Posts: 48

Rep: Reputation: 15
uncomment the error_log directive - this is a requirement of apache.
 
Old 05-05-2002, 08:08 PM   #3
tisource
Member
 
Registered: Feb 2002
Posts: 322

Original Poster
Rep: Reputation: 30
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
 
Old 05-08-2002, 05:14 PM   #4
tisource
Member
 
Registered: Feb 2002
Posts: 322

Original Poster
Rep: Reputation: 30
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....
 
Old 03-11-2004, 11:03 AM   #5
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 216

Rep: Reputation: 30
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.
 
Old 03-03-2006, 02:52 AM   #6
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
#
#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
 
  


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
Apache 2.0 Virtual Host? w0lfeyes Linux - Networking 1 05-03-2004 03:09 PM
apache and virtual host diverge Linux - Networking 2 01-11-2004 02:45 AM
Virtual host and apache Samspeed Linux - General 8 08-06-2003 07:41 AM
apache virtual host navinc Linux - Software 10 05-22-2003 12:16 PM
apache virtual host mimi Linux - General 1 04-06-2002 05:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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