t3h PHP

Discuss Programming
Post Reply
Doogee
administrator
administrator
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am

t3h PHP

Post by Doogee »

okie schmokies


Heres the firs problem ive encoutered.
Ive got a PHP script that writes to a file (visitors.txt) the info of the visitors.

The problem is that the script cant open visitors.txt i get the error


Warning: fopen("visitors.txt", "a+") - Permission denied in /var/www/html/index.php on line 10

so i suppose i have to make an emply visitors.txt file and chmod it. But what do i chmod it to?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

You have to chmod it such that the ID that your web server runs under has access to write to it. On Red Hat that user is "apache", I assume Mandrake is the same (do a "ps aux | grep http" to see the user your httpd runs under). If it is indeed "apache" then do this:

# cd /your/web/dir
# touch visitors.txt
# chown yourusername:apache visitors.txt
# chmod 660 visitors.txt

Which will make the file owned by you, assigned the group "apache" and is writable by both you and members of the "apache" group and noone else. Since httpd runs under the user "apache" which is a member of the "apache" group then anybody using your php script through the apache server will be able to write to the file.

Doogee
administrator
administrator
Posts: 261
Joined: Fri Jan 10, 2003 1:40 am

Post by Doogee »

sweet thanks that worked like a charm void main :P

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 »

For $15 dollars doogee you could get sams PHP in 24 hours from
www.everythinglinux.com.au

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Nothing really easy. I don't really see what the problem is. Don't give them an ID if you don't want them connecting. If you don't trust them on one operating system then you shouldn't trust them on any...

Post Reply