使用errno 13从php模块读取文件失败

Good day.
There is a PHP module ( .so) loaded within PHP. On MINIT stage it tries to read a file.
The file is a /tmp/aaa.txt The directory /tmp belongs to root and its permissions are set to 777.
The file /tmp/aaa.txt belongs to apache user and is also set to 777 permissions.

Module opens the file with VCWD_FOPEN(), which is define for
#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode TSRMLS_CC) which eventually is a fopen().

The VCWD_FOPEN fails with error 13 (permission denied).
The strange thing is, if I invoke the module manually ( #php -r 'echo "hi";' ) - it works. But when it runs from apache - it doesnt.
Anybody knows why?

Thank you

Found the problem. The user permission policy was enforced by SELinux. To disable it i typed #setenforce 0
#service httpd restart

Works now