Apache Server configuration support - How can I stop Apache from resolving symlinks?

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > February 2006 > How can I stop Apache from resolving symlinks?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How can I stop Apache from resolving symlinks?
Gnuru

2006-02-23, 10:32 am

I am trying to stop Apache & php from resolving the real files pointed to by symlinks. I have a php CMS that I use to host dozens of sites using Apache virtual hosting features. I need all the sites to run the exact same php CMS code but use their unique directories to host the different config files. The problem is that Apache runs the php scripts from the directory that the links point to and not the directory where the site is. This is a big problem as the CMS tries to read a configuration file that is in a relative location to the php script like ../config.php.

root@ttyq0[~]# ls -l /usr/local/cms
-rw-r--r-- 1 user users 20 Jan 16 02:17 index.php
drwxr-xr-x 9 user users 4096 Feb 22 16:40 admin
root@ttyq0[~]# ls -l /vhost/test01.com/var/www/html/
-rw-r--r-- 1 user users 20 Jan 16 02:17 config.php
lrwxrwxrwx 1 root root 31 Feb 22 14:05 index.php -> /usr/local/cms/index.php
lrwxrwxrwx 1 root root 31 Feb 22 14:05 admin -> /usr/local/cms/admin
root@ttyq0[~]# cd /vhost/test01.com/var/www/html/admin/
root@ttyq0[admin]# pwd
/vhost/test01.com/var/www/html/admin
root@ttyq0[admin]#

Bash is doing what I need. It sees the current directory as the full path of the symlink.

The admin.php at this point only has system("pwd"); in it and it prints out /usr/local/cms/admin as the directory it is in, not what I want. It will never see the ../config.php file.

I tried doing this
chdir ($_SERVER[DOCUMENT_ROOT]."/".$_SERVER[REQUEST_URI]);
but it still resolves the link and does not accept the path that I constructed.

I tested php CLI and it works like bash as expected.

I have the DocumentRoot set wtih "Options Indexes MultiViews FollowSymLinks"

Using FollowSymLinks is the only way I know of to allow the sites to runs as links to the common php code. What I think is happening is Apache first finds what the symlink points to then changes to that directory rather then reading the conents of the files where Apache finds them.

How can I make Apache use the symlink and stop trying to resolve the original files?
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com