iamgroot iamgroot - 3 months ago 5
PHP Question

Php doesn't read specific directory?

Something strange happens with my centos server. I have an asterisk server and I need to access to the recording dir. But it is impossible.

The dir /var/spool is unreadable. I can access with ssh with root and apache users, but from php it is impossible.

I don't know why!! This dir and /var/test/ has the same permissions (owner, group, chmod 755, ALL).

I use this php code:

I try to use exec function (works from another dirs), is_readable, file_get_contents but nothing :(

function wav_callid($id) {
$id = (int) $id;
$filename = 'cid'.$id.'.wav';
$path = '/var/spool/asterisk/monitor/' . $filename;
$tmp_path = '/tmp/' . $this->global_model->generate_random_hash();
exec("cp '$path' '$tmp_path'");
var_dump(is_readable('/var/spool')); // RETURN FALSE
var_dump(scandir('/var/spool')); // RETURN FALSE
var_dump(file_get_contents($path)); // RETURN FALSE

var_dump(is_readable('/var/test')); // RETURN TRUE
var_dump(scandir('/var/test')); // RETURN ARRAY

/*header('Content-Description: File Transfer');
header('Content-Type: audio/x-wav');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo file_get_contents($tmp_path);*/


What do I have to do?

Sorry for my bad english.



Selinux was blocking this dir.

Command for Centos 6:

 echo 0 >/selinux/enforce

And reboot.