LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-10-2009, 10:29 AM   #1
SeaborneClink
LQ Newbie
 
Registered: Feb 2009
Posts: 4

Rep: Reputation: 0
Unhappy VirtualHost directing to the wrong directory.


Okay, so I've got a couple sites enabled, say site2.com and site3.com

site2.com should direct to /var/www/site2.com
site3.com should direct to /var/www/site3.com
mydomain.com along with any wildcards (ip, another domain with A record to my ip) should direct to /var/www


Lets say mydomain.com is my site, and has a documentroot of /var/www, and uses the 'default' apache config. Site2.com and site3.com have their own config files with custom directives.

mydomain.com being the default, wildcard, catch all, should direct all unhandled requests to /var/www/

site2.com directs correctly to /var/www/site2.com
www.site2.com also, correctly directs to /var/www/site2.com

Here's where the problem arises.

site3.com erroneously directs to /var/www/site2.com
HOWEVER
www.site3.com directs correctly to /var/www/site3.com

It is this site, and this site only, that mistakenly directs to the other folder. I have tried.
Code:
rm /etc/apache2/sites-available/site3.com 
cp /etc/apache2/sites-available/site2.com /etc/apache2/sites-available/site3.com
searched for all instances of 'site2.com' in the new file, and replaced it with site3.com. Complete insuring a working config from site2 replaced the config from site3, and verified that http://site3.com continues to direct to /var/www/site2.com

I've spent about two days trying to get to the bottom of this with a user from ubuntuforums.org, and we've both come up stumped as to why this site is misbehaving.

I even went so far as to completely remove and purge apache2 from my box, and after a completely fresh install, it still doesn't work.

It is this site, and completely this site only that for some reason doesn't work.

/etc/apache2/sites-available/
default
site2.com
site3.com

/var/www/
site2.com
site3.com
index.php

default
Code:
<VirtualHost *>
	ServerAdmin webmaster@localhost
	
	DocumentRoot /var/www/
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options -Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
		# This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                #RedirectMatch ^/$ /apache2-default/
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined
	ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
site2.com
Code:
#
#  site2.com (/etc/apache2/sites-available/site2.com)
#

<VirtualHost *>
        ServerAdmin admin@site2.com
        ServerName  site2.com
        ServerAlias www.site2.com

        # Indexes + Directory Root.
        Options -Indexes
	DirectoryIndex index.php index.html
        DocumentRoot /var/www/site2.com/

        # CGI Directory
        ScriptAlias /cgi-bin/ /var/www/site2.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /var/log/apache2/site2.com/error.log
        CustomLog /var/log/apache2/site2.com/access.log combined
</VirtualHost>
site3.com
Code:
#
#  site3.com (/etc/apache2/sites-available/site3.com)
#

<VirtualHost *>
        ServerAdmin admin@site3.com
        ServerName  site3.com
        ServerAlias www.site3.com

        # Indexes + Directory Root.
        Options -Indexes
	DirectoryIndex index.php index.html
        DocumentRoot /var/www/site3.com/

        # CGI Directory
        ScriptAlias /cgi-bin/ /var/www/site3.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /var/log/apache2/site3.com/error.log
        CustomLog /var/log/apache2/site3.com/access.log combined
</VirtualHost>
httpd.conf is empty
ports.cong contains
Code:
NameVirtualHost *
Listen 80
Unable to post the apache2.conf due to message character limits. If anyone would like me to post that just go ahead and say so.

If anyone would like to take a look at the unedited config files, you're more than welcome to, just send me a PM and I will give you the actual website URL's and the config files.
 
Old 02-11-2009, 04:37 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi

What's in "/etc/apache2/sites-enabled/"? It should contain 3 symlinks, one for each site, pointing to the files in "/etc/apache2/sites-available".

Try
sudo a2ensite site2.com
sudo a2ensite site3.com

This will make the symlinks. Apache2 looks in sites-enabled, not sites-available.

Also try this:
apache2ctl configtest

It might give you a clue about what is wrong.
 
Old 02-12-2009, 06:28 AM   #3
SeaborneClink
LQ Newbie
 
Registered: Feb 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Guttorm View Post
Hi

What's in "/etc/apache2/sites-enabled/"? It should contain 3 symlinks, one for each site, pointing to the files in "/etc/apache2/sites-available".

Try
sudo a2ensite site2.com
sudo a2ensite site3.com

This will make the symlinks. Apache2 looks in sites-enabled, not sites-available.

Also try this:
apache2ctl configtest

It might give you a clue about what is wrong.
They're there. Otherwise http://www.site1.com wouldn't work

apache2ctl configtest
Syntax OK
 
Old 02-12-2009, 10:38 AM   #4
chitambira
Member
 
Registered: Oct 2008
Location: Online
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 51
This could be a dns issue. You probably have a cname for www.site3.com correctly configure, but site3.com is not. As a result, site3.com resolves to the host IP and looks for the immediately available vhost listening on port 80, which happens to be site2.com
 
Old 02-16-2009, 12:44 AM   #5
SeaborneClink
LQ Newbie
 
Registered: Feb 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chitambira View Post
This could be a dns issue. You probably have a cname for www.site3.com correctly configure, but site3.com is not. As a result, site3.com resolves to the host IP and looks for the immediately available vhost listening on port 80, which happens to be site2.com
None of my other sites have CNAMEs set. They all use A records and yet work correctly.

I've deleted all of my A records and reset them up probably 3 or 4 times. After waiting for changes to propagate, I'm still faced with the same end results.

www.site#.com
site#.com

work for all of my other domains, except this one.
 
Old 02-17-2009, 03:11 AM   #6
chitambira
Member
 
Registered: Oct 2008
Location: Online
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 51
Try these troubleshooting steps:
-clear the cache and cookies of browser you are using
-check permissions of the files site2.com and site3.com
-Try putting the vhost configs into one file and check waht happens
-whats in the logs? any errors?
-submit your dns entries
 
  


Reply

Tags
apache2, virtualhosts



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
directing samba directory to second harddrive fgw Linux - Newbie 1 07-05-2007 04:17 PM
Eterm starts in wrong directory jrdioko Linux - Newbie 3 12-27-2004 04:56 PM
Wrong modules directory used during boot ... tulear Linux - Software 3 10-30-2004 10:50 AM
wu-ftpd wrong login directory gkoutsog Linux - General 0 02-24-2004 06:18 AM
~user pointing to wrong directory jmckeown Linux - Newbie 2 11-03-2003 02:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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