LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 01-14-2005, 02:31 PM   #1
Moses420ca
Member
 
Registered: Jul 2003
Distribution: Ubuntu
Posts: 142

Rep: Reputation: 15
Apache - name based virtual hosts?


I have domain1.com and domain2.com both pointing to the same ip. I want each domain to have it's own web site but use only one server. I have a debian server with Apache version 1.3.33. With the current config, both domains pull up the same site (/home/www/domain1.com/). What's wrong with it?

Thanks for any help.
Drew


(snippet from httpd.conf)

NameVirtualHost *

<VirtualHost *:*>
ServerName domain1.com
DocumentRoot /home/www/domain1.com/
</VirtualHost>

<VirtualHost *:*>
ServerName domain2.com
DocumentRoot /home/www/domain1.com/
</VirtualHost>
 
Old 01-14-2005, 09:26 PM   #2
bdrake
Member
 
Registered: Aug 2004
Location: Montrose, CA
Distribution: Slackware, SuSE, OpenZaurus
Posts: 45

Rep: Reputation: 16
Um... you have domain1.com as the docroot for both virtual hosts in your snippet. Is that a typo when posting, or is it the real problem? That would cause the behavior you are seeing.

--Barry
 
Old 01-14-2005, 10:55 PM   #3
zoso
Member
 
Registered: Dec 2004
Distribution: Debian, Gentoo, Slackware, FreeBSD
Posts: 68

Rep: Reputation: 15
Yeah... you'll need to set the DocumentRoot variable to two different locations. If that wasn't a typo, though, it should work.
 
Old 01-15-2005, 01:19 PM   #4
Moses420ca
Member
 
Registered: Jul 2003
Distribution: Ubuntu
Posts: 142

Original Poster
Rep: Reputation: 15
unfortunately, it was a typo. Sorry. Here's the whole config because I can't figure this one out. I've changed the real domain names to domain1.com and domain2.com just for this posting.


### Section 1: Global Environment
ServerType standalone
ServerRoot /etc/apache
LockFile /var/lock/apache.lock
PidFile /var/run/apache.pid
ScoreBoardFile /var/run/apache.scoreboard
TimeOut 300
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 100
Include /etc/apache/modules.conf
<IfModule mod_status.c>
ExtendedStatus off
</IfModule>

### Section 2: 'Main' server configuration
Port 80
User www-data
Group www-data
#ServerAdmin user@domain.com
#ServerName host.domain.com
DocumentRoot /home/apache/html/
<Directory "/home/apache/html/">
order allow,deny
allow from all
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.shtml index.cgi index.php
</IfModule>
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
CacheNegotiatedDocs
UseCanonicalName off
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile /usr/share/misc/file/magic.mime
</IfModule>
HostNameLookups off
ErrorLog /home/logs/apache/error.log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{forensic-id}n\" %T %v" full
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{forensic-id}n\" %P %T" debug
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{forensic-id}n\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{forensic-id}n\"" forensic
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
#CustomLog /home/logs/apache/access.log common
#CustomLog /home/logs/apache/referer.log referer
#CustomLog /home/logs/apache/agent.log agent
CustomLog /home/logs/apache/access.log "combined"
<IfModule mod_log_forensic.c>
ForensicLog /home/logs/apache/forensic.log
</IfModule>
<IfModule mod_backtrace.c>
EnableExceptionHook On
#BacktraceLog /home/logs/apache/backtrace.log
</IfModule>
<IfModule mod_whatkilledus.c>
EnableExceptionHook On
#WhatKilledUsLog /home/logs/apache/whatkilledus.log
</IfModule>
ServerSignature Off
ServerTokens Minimal
<IfModule mod_alias.c>
Alias /icons/ /home/apache/icons/
<Directory "/home/apache/icons/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /error/ /home/apache/error/
<Directory "/home/apache/error/">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
<IfModule mod_autoindex.c>
IndexOptions FancyIndexing ScanHTMLTitles IconsAreLinks FoldersFirst
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/deb.gif .deb

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz

ReadmeName README.txt
HeaderName HEADER.txt

IndexIgnore .* *~ *# *,v *,t

</IfModule>

<IfModule mod_mime.c>
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .ee
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddCharset ISO-2022-JP .jis
AddLanguage pl .po
AddCharset ISO-8859-2 .iso-pl
AddLanguage pt .pt
AddLanguage pt-br .pt-br
AddLanguage lb .lu
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cs .cz

<IfModule mod_negotiation.c>
LanguagePriority en da nl et fr de el it ja pl pt pt-br lb ca es sv
</IfModule>

AddType application/x-tar .tgz
AddType image/bmp .bmp
AddType text/x-hdml .hdml

AddHandler cgi-script .cgi .sh .pl

<IfModule mod_include.c>
AddType text/html .shtml
AddHandler server-parsed .shtml
</IfModule>
</IfModule>

AddDefaultCharset on
<IfModule mod_setenvif.c>
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>

<IfModule mod_perl.c>
<IfModule mod_alias.c>
Alias /error/ /home/apache/error/
</IfModule>
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Location>
</IfModule>

<Location /server-status>
SetHandler server-status
Order allow,deny
allow from all
</Location>

#<Location /server-info>
# SetHandler server-info
# Order deny,allow
# Deny from all
# Allow from .your_domain.com
#</Location>

<Location /cgi-bin/phf*>
Deny from all
ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
</Location>

Include /etc/apache/conf.d
Include /etc/nagios/apache.conf

### Section 3: Virtual Hosts
NameVirtualHost *

<VirtualHost *:*>
#ServerAdmin webmaster@domain.com
DocumentRoot /home/apache/html/drew/
ServerName domain1.com
#ErrorLog logs/host.some_domain.com-error.log
#CustomLog logs/host.some_domain.com-access.log common
</VirtualHost>

<VirtualHost *:*>
#ServerAdmin webmaster@domain.com
DocumentRoot /home/public/
ServerName domain2.com
#ErrorLog logs/host.some_domain.com-error.log
#CustomLog logs/host.some_domain.com-access.log common
</VirtualHost>
 
Old 01-16-2005, 12:43 AM   #5
bdrake
Member
 
Registered: Aug 2004
Location: Montrose, CA
Distribution: Slackware, SuSE, OpenZaurus
Posts: 45

Rep: Reputation: 16
The way you have it set up, it should work. The following is all I can think of for now.

What address (name) are you using when trying to get to the second server? If you type "domain2.com", it should work. However, if you type "www.domain2.com", you will get the domain1 page. Since domain1 is listed first, any requests which do not have an *exact* match will default to displaying the domain1 page. To include multiple possibilities for names in a VirtualHost section, use the ServerAlias directive, placed within the appropriate VirtualHost section:

ServerAlias domain2.com *.domain2.com

I hope that helps.

--Barry
 
Old 01-16-2005, 12:00 PM   #6
Moses420ca
Member
 
Registered: Jul 2003
Distribution: Ubuntu
Posts: 142

Original Poster
Rep: Reputation: 15
Nice. That wasn't exactly what was happening but it fixed my problem anyway. It works great and that's probably a better configuration anyway.

Thanks a lot.
Drew
 
Old 01-16-2005, 12:29 PM   #7
bdrake
Member
 
Registered: Aug 2004
Location: Montrose, CA
Distribution: Slackware, SuSE, OpenZaurus
Posts: 45

Rep: Reputation: 16
Awesome! I'm glad it helped.

--Barry
 
Old 01-26-2005, 11:04 AM   #8
alejandroye
Member
 
Registered: May 2004
Location: SOUTH FLORIDA USA
Distribution: MANDRIVA / CENTOS
Posts: 146

Rep: Reputation: 15
HTTPD2.CONG

hello

I am usinig the new version of apache and need to configure as you do, www.domainone.com and www.domaintwo.com, one IP address, I just get 2 zone for those domain but I need to configure apache and I realized that I need to work with Vhosts.conf in this version apart that httpd2.conf where there is a line

Include conf/vhosts/Vhosts.conf

so, I edit Vhosts.conf and need help to configure

I am doing ok??

thanks


 
  


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
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
IP based virtual hosts problem adm1329 Linux - Networking 4 03-11-2004 10:40 AM
Apache/Virtual Hosts Help C-Squared Linux - General 9 08-04-2003 12:45 PM
Apache Virtual Hosts quozt Linux - Networking 1 07-29-2003 05:56 PM
Apache: Virtual hosts pk21 Linux - Software 15 10-08-2002 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:03 AM.

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