Daij-Djan
asked on
Give PHP writeaccess
I am running OSX 10.3.5 on a G4 PB.
I installed php5 and activated the in-built apache web server.
I activated personal websharing and put my site in my homedir:
~/Sites
Now, I have a script (residing in ./dominik/guestbook/ which needs to be able to WRITE in that directory. (It needs to be able to create new files!)
How do I do that?
I tried 'chmod -R 777 dominik/' to no success and 'chown -R www dominik/' which didn't change anything and just spit out an error. (No permission)
Any idea anybody?
Thanks,
Dominik
I installed php5 and activated the in-built apache web server.
I activated personal websharing and put my site in my homedir:
~/Sites
Now, I have a script (residing in ./dominik/guestbook/ which needs to be able to WRITE in that directory. (It needs to be able to create new files!)
How do I do that?
I tried 'chmod -R 777 dominik/' to no success and 'chown -R www dominik/' which didn't change anything and just spit out an error. (No permission)
Any idea anybody?
Thanks,
Dominik
Will chmodding "dominik/" also give full access permissions to the guestbook directory? Trying to chmod /dominik/guestbook/ directly may be worth a try.
ASKER
I did a chmod -r (so it is recursive and I checked the permissions... there a ok)
ASKER
phpinfo says safemode is off!
Check what user the webserver run as. (Type "ps aux" and look for httpd).
If the user is not nobody change nobody in the line under to correct username:
chown -R nobody:nobody ./dominik/guestbook/
If the user is not nobody change nobody in the line under to correct username:
chown -R nobody:nobody ./dominik/guestbook/
You have to set the apache user account as the owner of the file. Remember, php runs under apache; so whatever user account is running apache needs to get the access to the file (and get write permissions). Also, make sure you don't use root to run apache as this can cause huge secuirty problems. But, use a username like nobody or something similar.
AJ
AJ
aratani: just what I said...
ASKER
well... apache runs as www but chown isn 't working:
'chown: guestbook/: Operation not permitted'
'chown: guestbook/: Operation not permitted'
You will need to be the CREATOR of the directory or ROOT to be able to change the owner of the directory. In linux, type "su" then enter the root password to change the user to root.
Ok, since it's not running as user "nobody", you are probably not using the group "nobody" either. It is not really important. So ignore the group, and only change the owner:
Enter the command: "chown -R www ~/Sites/dominik/guestbook"
Ok, since it's not running as user "nobody", you are probably not using the group "nobody" either. It is not really important. So ignore the group, and only change the owner:
Enter the command: "chown -R www ~/Sites/dominik/guestbook"
ASKER
Well... changing the owner worked but still...
drwxr-xr-x 6 www Dominik 204 17 Sep 22:43 guestbook
error] PHP Warning: fopen("./guestbook/Dominik Pich.htm") [<a href='function.fopen'>func tion.fopen </a>]: failed to open stream: No such file or directory in /Users/Dominik/Sites/users /dominik/g uestbook/a dd entry.php on line 66
I try to open the file with fopen w+
drwxr-xr-x 6 www Dominik 204 17 Sep 22:43 guestbook
error] PHP Warning: fopen("./guestbook/Dominik
I try to open the file with fopen w+
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmm... aratani said just the same as I did in both of his answers. Just in other words.
No I didn't .. my second answer was very different .. ;)
Abhishek (AJ) Ratani
Abhishek (AJ) Ratani
I don't want a fight about points. But facts are facts:
aratani: I think you have got the ownership right if it shows what you said.
Yes, Daij-Djan said it himself: "changing the owner worked"
aratani: You are probably setting the wrong path...
Yes, I already said that: "Are you sure you have the correct path..."
So what new ideas did you come up with?
aratani: I think you have got the ownership right if it shows what you said.
Yes, Daij-Djan said it himself: "changing the owner worked"
aratani: You are probably setting the wrong path...
Yes, I already said that: "Are you sure you have the correct path..."
So what new ideas did you come up with?
No I'm sorry I believe I am entitled to some points,
This is what I said that was different from you, if that is all you care about,
1. I don't know how you've defined, but probably you've defined the fopen wrong.
2. Also, make sure you don't use root to run apache as this can cause huge secuirty problems.
3. Remember, php runs under apache; so whatever user account is running apache needs to get the access to the file (and get write permissions)
4. Basically, I gave more detailed explanations about the situation and what might be causing the problem.
I don't mind it if the author decides to award somebody the points. But, I agree with the split if the author has nothing to say.
AJ
This is what I said that was different from you, if that is all you care about,
1. I don't know how you've defined, but probably you've defined the fopen wrong.
2. Also, make sure you don't use root to run apache as this can cause huge secuirty problems.
3. Remember, php runs under apache; so whatever user account is running apache needs to get the access to the file (and get write permissions)
4. Basically, I gave more detailed explanations about the situation and what might be causing the problem.
I don't mind it if the author decides to award somebody the points. But, I agree with the split if the author has nothing to say.
AJ
1. Yes, he defined the fopen with the wrong PATH
2. True, but later he said apache runs as www, so this isn't part of the solution
3. I already said that (Check what user the webserver run as...)
4. True, but you still said the same things in other words
I don't want to argue more about these points, just split them!
2. True, but later he said apache runs as www, so this isn't part of the solution
3. I already said that (Check what user the webserver run as...)
4. True, but you still said the same things in other words
I don't want to argue more about these points, just split them!
If safe mode is turned on, php will only have write access to files/dirs with the same owner as the owner of the apache process (usually nobody on linux, don't know in OSX).
Read more about safe mode here:
http://no2.php.net/features.safe-mode