Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Give PHP writeaccess

Posted on 2004-09-25
19
Medium Priority
?
847 Views
Last Modified: 2008-07-03
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
0
Comment
Question by:Daij-Djan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 4
  • +1
19 Comments
 
LVL 1

Expert Comment

by:x-tinct
ID: 12151093
Is safe mode turned on? Use phpinfo() to see what settings PHP use. To change edit php.ini.

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
0
 
LVL 4

Expert Comment

by:Skonen
ID: 12151377
Will chmodding "dominik/" also give full access permissions to the guestbook directory? Trying to chmod /dominik/guestbook/ directly may be worth a try.
0
 
LVL 5

Author Comment

by:Daij-Djan
ID: 12151505
I did a chmod -r (so it is recursive and I checked the permissions... there a ok)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Author Comment

by:Daij-Djan
ID: 12151942
phpinfo says safemode is off!
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12152164
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/
0
 
LVL 4

Expert Comment

by:aratani
ID: 12153698
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
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12153895
aratani: just what I said...
0
 
LVL 5

Author Comment

by:Daij-Djan
ID: 12154250
well... apache runs as www but chown isn 't working:
'chown: guestbook/: Operation not permitted'
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12154281
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"
0
 
LVL 5

Author Comment

by:Daij-Djan
ID: 12154462
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'>function.fopen</a>]: failed to open stream: No such file or directory in /Users/Dominik/Sites/users/dominik/guestbook/add entry.php on line 66

I try to open the file with fopen w+
0
 
LVL 1

Accepted Solution

by:
x-tinct earned 252 total points
ID: 12154512
Are you sure you have the correct path for the guestbook. Take a look at the directory of the php file you are running:
/Users/Dominik/Sites/users/dominik/guestbook/add entry.php

Where is the guestbook lokated? Earlier you said it was here:
/Users/Dominik/Sites/dominik/guestbook

Make sure you changed the ownership of the right directory.
0
 
LVL 4

Assisted Solution

by:aratani
aratani earned 248 total points
ID: 12156583
I think you have got the ownership right if it shows what you said.

Probably, your fopen is going wrong. You are probably setting the wrong path in your fopen, since it trying to access the wrong file. Is this what you do,

fopen ("add entry.php", "w+");

I don't know how you've defined, but probably you've defined the fopen wrong.

Take care

AJ
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12493118
Hmm... aratani said just the same as I did in both of his answers. Just in other words.
0
 
LVL 4

Expert Comment

by:aratani
ID: 12494728
No I didn't .. my second answer was very different .. ;)

Abhishek (AJ) Ratani
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12513310
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?
0
 
LVL 4

Expert Comment

by:aratani
ID: 12513636
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
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12516884
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!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question