Page 1 of 1

Permissions error?

Posted: Mon Feb 14, 2005 9:55 am
by nix
Every time I attempt to write to text files online, I get a permissions error. Because my host limits me to just 2 MYSQL DB's I use text files for learning first. Whenever I read from a text file it will usually do it no prob, but when I attempt to write to one, it refuses. examples here: http://www.nixopax.com/php/online.php

http://www.nixopax.com/flash/chronotrigger.php

All I need to do is provide a simple counter with php. Does anyone here know how?

Posted: Mon Feb 14, 2005 10:12 am
by feyd
your script requires write privledges to the counter file. The script likely runs under a different user than your account, so you need to given write access to everyone 0757 or similar.

If you search for "flat-file counter" you should find several examples/threads about it.

Posted: Mon Feb 14, 2005 10:21 am
by nix
I think I have to set CHMOD 777 to it otherwise permissions aren't granted.

Posted: Mon Feb 14, 2005 11:42 am
by timvw
It is very unlikely you need 777. The only thing you need to do is to find out who is executing your php script. That is usually the user that is running the apache program. Usually that user is called www-data or nobody. Then you have to find out if that user is part of the group that owns the file or not. Let's assume the user is not in the group, thus belongs to others.


First you want to allow that user to enter /home/user/web
chmod o+x /home/user/web

And you want to give rights to create files in /home/user/web
chmod o+w /home/user/web

If you want to give rights to read the list of files in /home/user/web
chmod o+r /home/user/web

You can find some more background info here:
http://www.freebsd.org/doc/en_US.ISO885 ... sions.html
offcourse there are a zillion other sites too :)