Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-02-2011, 01:11 PM   #1
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Debian
Posts: 78

Rep: Reputation: 23
Question Apache (PHP) access files outside of www root


I have my apache root as /var/www/html and have a sub-folder there as /var/www/html/Fontan.
The other files are located as /mnt/draid/Pictures/

In /var/www/html/Fontan I have a PHP script using opendir() to try to access the files to output a simple <img> tag for each. But it won't work.

If I go for other files with opendir('../otherfolder/Pictures/') it works fine, but not when I try opendir('/mnt/draid/Pictures/'). I have also tried to create a softlink as /var/www/html/Pictures pointing to /mnt/draid/Pictures and then using opendir('Pictures'). But it still won't work.

The opendir() does not get executed correctly (I only proceed if it is correctly assigned) which I assume is due to the same reason as if I try to access the files directly.

The error it gives me when I try to reach the files directly http://localhost/Fontan/Pictures/afile.jpg is access denied.

I've tried adding the web group to the softlink (chown -h) and the real folder, set everything as executable and even set chmod 777 on all of it. But nothing works.

Any assistance would be much appreciated.
Old 05-02-2011, 02:45 PM   #2
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,891

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608

This could be due to a variety of reasons:
The apache user does not have read rights on /mnt/draid/Pictures partition. Check the mount options and adjust user permissions
If you're using a rhel based distro it could be SELinux. For debian based it could be apparmor.
Last but not least you need:
<Directory /mnt/draid/Pictures>
Allow from All

Last edited by bathory; 05-03-2011 at 01:40 PM. Reason: typos


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] apache (running in Ubuntu 10.10) can't access php files W_Chevezman Linux - Software 12 02-24-2011 04:14 PM
After moving PHP files to /var/www they no longer are seen as hosted php files scheidel21 Linux - Server 9 03-01-2010 08:16 AM
FTP client can't access files in /var/www/html (Apache ) dshap Linux - Newbie 8 06-03-2009 01:12 PM
Access files outside the document root for Apache vwvr9 Linux - Server 3 07-28-2008 06:28 PM
Apache Web Server - access from the www vesta41 Linux - Software 8 01-07-2004 07:55 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration