Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache2 + dynamic-vhosts = broken PHP document_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
sigmalll
Guru
Guru


Joined: 24 Aug 2003
Posts: 332

PostPosted: Tue Aug 31, 2004 2:18 pm    Post subject: Apache2 + dynamic-vhosts = broken PHP document_root Reply with quote

I have a simple vhost setup using dynamic-vhosts.conf

Code:
#Simple dynamic virtual hosts
#
#   This extract from apache2.conf implements the virtual host arrangement
#   outlined at http://www.apache.org/docs/vhosts/mass.html, using
#   mod_vhost_alias.

# get the server name from the Host: header
UseCanonicalName Off
#
# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
#
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /mnt/raid/Net/%0/dev/htdocs
#VirtualScriptAlias  /www/hosts/%0/cgi-bin
#
#   This configuration can be changed into an IP-based virtual hosting
#   solution by just turning UseCanonicalName Off into UseCanonicalName DNS.
#   The server name that is inserted into the filename is then derived from
#   the IP address of the virtual host.



<Directory /mnt/raid/Net>
        Options Includes Indexes FollowSymLinks
        AllowOverride FileInfo
        allow from all
</Directory>


All working fine, I can create new hosts by just creating the relavent dirs.

The problem is that for all my vhosted sites the PHP variable document_root returns the default value from apache2.conf NOT the document root of the actual vhost

how can I get this fixed?
Back to top
View user's profile Send private message
sigmalll
Guru
Guru


Joined: 24 Aug 2003
Posts: 332

PostPosted: Fri Sep 03, 2004 11:43 am    Post subject: Reply with quote

bump - anybody?
Back to top
View user's profile Send private message
yerhus
n00b
n00b


Joined: 18 Apr 2002
Posts: 7
Location: Portugal

PostPosted: Mon Dec 20, 2004 3:47 pm    Post subject: Reply with quote

I have the same problem... is there any solution?
Back to top
View user's profile Send private message
sigmalll
Guru
Guru


Joined: 24 Aug 2003
Posts: 332

PostPosted: Tue Dec 21, 2004 11:12 am    Post subject: Reply with quote

I ended up using a little PHP to work out the real document root. I have a shared library of code that I pointed the apache document root at and all my pages start by loading an init script thats in this 'common' document root.

I then work out the actual document root and update that server var.

Dunno how useful the following will be to you

Code:

$root = explode("httpdocs", dirname($_SERVER['SCRIPT_FILENAME']));
$root = $root[0].'httpdocs';
$_SERVER['DOCUMENT_ROOT'] = $root;
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