Forum Moderators: phranque

Message Too Old, No Replies

Access a file outside DocumentRoot

         

squibs

3:49 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



I understand that access outside DocumentRoot is not generally possible, but I have a scenario with multiple sites on the same server using the same scripts.

I would like to put these scripts in a shared folder that can be referenced by each domain from an include in a script that lives within that domain's documen root. i.e.

main file is /var/www/vhosts/<domain>/httpdocs/myfile.php

and it has a php include statement for

/var/www/vhosts/sharedscripts/includeme.php

I have tried to set this up by creating the dir and file in it, and changing owner and group on file and dir to apache, but it doesn't work.

Can it be done? Thanks for reading...

jdMorgan

1:38 am on Apr 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Create a "private" script directory for each user, named, for example, "cgi-local". In that directory put a symbolic link to the actual server filepath to the shared scripts using the *nix command line.

Alternately, if you have server configuration access, you can create a ScriptAlias to accomplish the same thing in a different way (See Apache mod_alias ScriptAlias directive).

Jim

squibs

10:06 am on Apr 9, 2007 (gmt 0)

10+ Year Member



Thanks for the reply. I tried the symbolic link approach with no joy.

ln -s <shared scripts location> myscripts

I verified that the link worked, and changed group and owner to apache, but I still don't seem to be able to access files through the link with my php scripts.

I have a test script that includes a script with just an echo command, and the main script uses readdir to do a directory listing. The script works fine on regular directories, but will not work on the link.