Page 1 of 1

Need help with permissions!

Posted: Wed May 15, 2002 11:01 am
by DrT
I am trying to get a script running on my host that creates or overwrites a small text file on my hosts web server. I am using the command fp$=fopen("test.txt", "w") and all I get back is the error Warning: fopen("test.txt", "w") - Permission denied in /usr/local/psa/home/vhosts/milltech-php.com/httpdocs/scripts/submit.php on line 9

If I use the "r" parameter instead then its quite happy!

The system is running PHP v4.1.0 on Apache and phpinfo.php returns the following for configuration " './configure' '--with-apxs=apxs' '--prefix=/home/builder/psa-dummies/psa/apache/../release/usr/local/psa/apache' '--with-system-regex' '--with-config-file-path=/usr/local/psa/apache/conf' '--disable-debug' '--disable-pear' '--enable-sockets' '--enable-track-vars' '--without-gd' '--with-mysql=/home/builder/psa-dummies/psa/apache/../release/dist/usr/local/psa/mysql' '--with-iodbc=/home/builder/psa-dummies/psa/apache/../release/lib/libiodbc' '--with-imap=/home/builder/psa-dummies/psa/apache/../release/lib/imap-cclient'"

Any help you might be able to give me to tell me whats going wrong or what permissions aren't right here would make me extremely gratefull!

Thanks

Tim west

Posted: Wed May 15, 2002 11:04 am
by mydimension
most likely the permission on that file are r-xr-xr-x when they need to/should be rwxrwxrwx. so try doing this:

chmod 777 test.txt

that should make everything a-okay

Can't be just that!

Posted: Wed May 15, 2002 11:09 am
by DrT
Thanks for the thought but when I first fire up the script the file doesn't actually exist so there's nothing to set the permissions on! I was hoping that the script would actually create the file 'cos thats what the book says the "w" parameter will do :(

Posted: Wed May 15, 2002 11:13 am
by mydimension
try doing the chmod command on the containing directory. could be that the directory is not set to allow the PHP engine to create files, but since you own it, its not that hard of a problem to fix

Thanks

Posted: Wed May 15, 2002 11:20 am
by DrT
Thanks, I was just coming to that conclusion my self. I'll give it a try.

Tim west

Posted: Wed May 15, 2002 11:39 am
by enygma
btw - 777 is a very scary permission to set.
Here's a brief overview:

1 - exe
2 - write
4 - read

order: user/group/world (done in groups of three - rwx)

so that, if you wanted to make it full permissions for the user that owns it:
-rwx------
or
1+2+4 = 7 so .... chmod 700 filename

or, to make it read only for everyone, and allow only the user to write to it:
-rw-r--r--
or
4+2 = 6
4 (read) so..... chmod 644 filename

Posted: Wed May 15, 2002 5:09 pm
by mydimension
yeah, its scary but alot of servers run their httpd as user 'nobody' and therefore needs global access to modify the files.mine is setup that way and im guessing that DrT's is set up that way as well.

Posted: Thu May 16, 2002 1:49 am
by DrT
Yep, that was my problem and now I can write to a file! Thanks guys!