Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hosting multi websites, all sites use the same doc root
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ImAmMe
n00b
n00b


Joined: 10 Feb 2006
Posts: 61

PostPosted: Sun Aug 19, 2012 5:03 pm    Post subject: hosting multi websites, all sites use the same doc root Reply with quote

Apache serving wrong document root, i can not figure why for the life of me. I have done some googling found a few tutorials on subject and i dont understand why i can not change the document root, its allways the same. I thought it was using the default website configuration, i dont believe so anymore.

fun facts
- im using one machine, one ip
- I can ping both foo, and altsite. so i can resolve the addresses ok.
- For debugging i have all files and directory set to 755, under /var/www/*
- right now im not getting any complaints from Apache on reload/restart



emerge -pv apache
Code:
[ebuild   R    ] www-servers/apache-2.2.22-r1  USE="ssl threads -debug -doc -ldap (-selinux) -static -suexec" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -auth_digest -authn_dbd -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -proxy_scgi -reqtimeout -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB


/etc/apache2/httpd.conf
Code:

....
Include /etc/apache2/modules.d/*.conf
NameVirtualHost *:80
Include /etc/apache2/vhosts.d/*.conf


/etc/apache2/vhosts.d/00_default_vhost.conf
Code:

<IfDefine DEFAULT_VHOST>
Listen 80

# Use name-based virtual hosting.
#NameVirtualHost *:80   ### put this in /etc/apache2/httpd.conf

ServerName foo
 
<VirtualHost *:*>
        ServerName localhost
        Include /etc/apache2/vhosts.d/default_vhost.include

        # Redirect http -> https, rewrite
        RewriteEngine On
        RewriteCond %{HTTPS} !on
        RewriteRule ^/(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R]


        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache
        </IfModule>
</VirtualHost>
</IfDefine>



/etc/apache2/vhosts.d/foo.conf
Code:
<VirtualHost *:80>
        ServerName foo
        DocumentRoot "/var/www/localhost/htdocs"
        <Directory "/var/www/localhost/htdocs" >
                Options Indexes
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>


/etc/apache2/vhosts.d/altsite.conf
Code:
<VirtualHost *:80>
        ServerName dev.altsite.com
        DocumentRoot "/var/www/altsite/htdocs"
        <Directory "/var/www/altsite/htdocs" >
                Options Indexes
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>



Any suggestions?
thanks for taking a gander
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Aug 19, 2012 6:09 pm    Post subject: Reply with quote

your virtual hosts all listen on *:80, which matches every domain. you could this a some kind of last resort vhosts for any unmatched domains, but if that wildcard vhosts is put first, it will always match.

use something like
Code:
<VirtualHost foo:80>
        ServerName foo
        DocumentRoot "/var/www/localhost/htdocs"
        <Directory "/var/www/localhost/htdocs" >
                Options Indexes
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>


any additional names (aliases, ip address or whatever it should listen on) can be introduced with ServerAlias.


HTH
V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
ImAmMe
n00b
n00b


Joined: 10 Feb 2006
Posts: 61

PostPosted: Sun Aug 19, 2012 7:26 pm    Post subject: Reply with quote

thank u for the suggestion...
but still im getting the wrong directory for the altsite
I tried changing both VirtualHost line at separate times and still no luck.

I played with the default_vhost.include file changing the DocumentRoot and Directory. And doing that corrected my altsite root, but my foo site not right now. So i guess im having an issue with my default website catching all the request...right?
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Aug 19, 2012 7:31 pm    Post subject: Reply with quote

try disabling the DEFAULT_VHOST - I still have a feeling that it is interfering. from the little information i have, the default_vhost will be read before the other vhosts, and therefore overriding them.

V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
ImAmMe
n00b
n00b


Joined: 10 Feb 2006
Posts: 61

PostPosted: Sun Aug 19, 2012 8:18 pm    Post subject: Reply with quote

ok...
- removed the DEFAULT_HOST flag service config file
- moved the Listen, ServerName to /etc/apache/httpd.conf

restarted the service. Still no change.

Im more than happy to share any more information, i dont know what share to make this easy for u
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Aug 19, 2012 11:29 pm    Post subject: Reply with quote

how are you accessing the pages? what browser? what url?
are you using dns resolution? or are the hosts added /etc/hosts?
is the cache disabled? did you clean it between the tries?


just some random thoughts. - i am especially curious about the last ones.
V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
ImAmMe
n00b
n00b


Joined: 10 Feb 2006
Posts: 61

PostPosted: Mon Aug 20, 2012 12:07 am    Post subject: Reply with quote

im using several browers
win7 box: firefox 14.0.1, Chrome 21.0.1180.79
gentoo box: elinks 0.11.7

firefox and chrome are the primary two im testing with. Now i havent been very religious about clear dns between goes. But it seems to find 'foo' and dev.altsite.com most every time. but just consistently displays the wrong document root for the dev.altsite.com. I have tried from a three different boxes, one of which is the local box. Get the same result every time

the machine running the apache server, is running dnsmasq-2.57.
my /etc/hosts
Code:
10.11.11.8 foo
10.11.11.8 dev.altsite.com

it doesnt seem to matter if the domain names are on separate lines or not. After every edit i restart dnsmasq and clear out flush dns in browsers.

url im using for access is
https://foo
https://dev.altsite.com
and
http://foo
http://dev.altsite.com


any more questions?
Back to top
View user's profile Send private message
s_bernstein
Apprentice
Apprentice


Joined: 11 Mar 2006
Posts: 172
Location: Bremen, Germany

PostPosted: Mon Aug 20, 2012 6:27 am    Post subject: Reply with quote

Stupid question, but you did activate vhost support in your /etc/conf.d/apache, right?

On the other hand, some hints:

1. Your vhost.d/*.conf seems to be correct. Also, you can mix the default vhost with own vhosts without problems and <VirtualHost *:80>
is also correct.

2. You do not need to add NameVirtualHost statement to httpd.conf. The vhost module will do this for you.

3. Your server must be able to resolve the hostnames - always double check with nslookup

4. You can check your setup with apache2ctl configtest. There was a -S parameter to that commend to test vhost setup but taht doesn't seems to work anymore.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum