LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-02-2011, 12:11 PM   #1
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Mandriva
Posts: 76

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


Hello,

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, 01:45 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,732

Rep: Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584
Hi,

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:
Code:
<Directory /mnt/draid/Pictures>
Allow from All
<Directory>
Regards

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


Reply


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 03: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 07:16 AM
FTP client can't access files in /var/www/html (Apache ) dshap Linux - Newbie 8 06-03-2009 12:12 PM
Access files outside the document root for Apache vwvr9 Linux - Server 3 07-28-2008 05:28 PM
Apache Web Server - access from the www vesta41 Linux - Software 8 01-07-2004 06:55 PM


All times are GMT -5. The time now is 10:23 AM.

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