tags:

views:

64

answers:

3

Help! PHP cannot write to any files in my web directory. I don't know why! I have the permissions of the file set to 777, but it is not working! Here is the code in question:

<?php

if ($f=fopen('test.txt', 'a'))
        echo 'file opened';
fclose($f);

Nothing is being echoed! I don't know why :(.. the userid and gid is 0:0 from the script, and if I try to chown to that it doesn't work.

Please help I need this fixed asap this should be an easy thing to do but the damn server is being difficult.

And its running on Cent OS if thats any help..

+1  A: 

You'll need to enable the appropriate SELinux booleans and label the directory with the appropriate file context if you want to write files there.

Or you could disable SELinux. But don't do that.

Ignacio Vazquez-Abrams
*If* OP is using SELinux.
Chris
A: 

try to use absolute path. might be other dir then you think. also might be network file system that cannot be accessed as root.

ohadshai
A: 

If you're just uploading this php to a typical multi user server and you have 777 permissions but cannot write files, the most likely "culprit" is suPHP.

In a system with the suPHP module installed, one cannot have 777 permissions.

You can check for the existence of this installed on your system with phpinfo().

Shawn Leslie
Wouldn't this return a 500 Internal Server Error then?
webbiedave
We'd have to ask the Original Poster. "Blank Page" could mean a lot of things in my experience of hearing other's descriptions of errors.
Shawn Leslie