You are not logged in.
I'm having problems accessing a directory from a php script. I know the php is correct since I had it loaded on my raspberry pi and it worked there, but the arch apache permissions are a little more strict. The relevant portions of my httpd.conf are:
<Directory />
Options FollowSymLinks Indexes
AllowOverride all
Order deny,allow
Allow from none
</Directory>
<Directory /media/external/hosting>
Options FollowSymLinks Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>and in my php, I try to access the folder with:
$dir=opendir("/media/external/hosting/");
while (($file=readdir($dir)) !== false)
{
if ($file != "." and $file != ".." and $file != "index.php")
{
array_push($files, $file);
}
}
closedir($dir);I have tried looking at other explanations of how to do this, and mine seems to match, but it's not working. Is there something wrong with my httpd.conf? Is this the proper way to allow access to this directory?
Offline
Have you tried adding "/media/external/hosting/" to the open_basedir in php.ini?
From the php docs:
open_basedir string
Limit the files that can be accessed by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off.When a script tries to access the filesystem, for example using include, or fopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to access it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir .
I don't have much php experience but my understanding is that it will refuse to access anything on filesystem unless it is explicitly allowed to do so.
Last edited by kermana (2014-03-12 23:21:08)
Offline
Order deny,allow Allow from none
Are you using Apache 2.2? If not, this is wrong. Seek out the mega-thread on the apache update, or/and read the migration notes for Apache 2.2 -> 2.4.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
I am using Apache 2.2.
Offline
I also added /media/external/hosting/ to my open_basedir and it didn't work. Still no response from the page.
Offline
What are the current permissions of the directory where the file in question resides?
R.
Offline
Fully open. rwx for all, owned by my local user with the users group. I don't really care who owns it, that's just what it's set as.
Offline
Are you using "plain old" PHP or are you using a Framework?
p.s: Also, what do you see in your /var/log/httpd/error_log?
Last edited by ralvez (2014-03-15 04:56:41)
Offline
There are just a ton of warnings:
PHP Warning: readdir() expexts parameter 1 to be resource, boolean given I'm assuming these are all from the opendir not working, so it returned false.
Offline