PHP Permission Error

Discussion in 'Installation/Configuration' started by Rapid2214, Aug 17, 2010.

  1. Rapid2214

    Rapid2214 New Member

    Hi,
    I'm trying to write to a .txt file in my web directory, although i'm getting a permission denied error.
    I think the problem is that to write to the file it must have www-data permission? Shouldn't it already?
    Here is the result of ls -l
    Code:
    -rw-r--r-- 1 web24 client1 1512 2010-08-17 14:24 index.php
    -rw-r--r-- 1 web24 client1    0 2010-08-17 14:17 moss_visits.txt
    -rw-r--r-- 1 web24 client1    0 2010-08-17 13:48 roy_visits.txt
    -rw-r--r-- 1 web24 client1  412 2010-08-17 14:03 visit.php
    
    Why can't www-data write to moss_visits.txt or roy_visits.txt?
    I worried this may effect my clients....

    Thanks

    Marty

    An undesired fix was to redefine the permissions to www-data client1, which was not ideal and prevented FTP access.

    Help :S
     
  2. Mark_NL

    Mark_NL New Member

    -rw-r--r-- 1 web24 client1 0 2010-08-17 14:17 moss_visits.tx

    user web24 may: read, write
    group client1 may: read
    world (that's www-data as well) may: read

    so no, www-data may not write to that file, the solution would be giving the world write rights .. so:
    Code:
    chmod 666 moss_visits.txt roy_visits.txt
     
  3. Rapid2214

    Rapid2214 New Member

    Yes, that fine if it's only my website...

    How can i give all clients world write permission, i tried chmod 775 -R /var/www

    But it took down all the websites with a 403 error.

    Any idea?
    Marty
     
  4. Mark_NL

    Mark_NL New Member

    tip1: NEVER use "-R" in linux commands if you have no clue what the command does ..

    because all your filepermissions are messed up now ..
    you don't want all 'clients' world write persmission, that's a huge security risk.
    only give world write permissions to files you know it's oke it's going to be written by apache (f.e.) ..
     
  5. Rapid2214

    Rapid2214 New Member

    I do know what '-R' does, but didn't expect that effect. and btw, i had backups which i restored to, so my permissions arent 'messed up'.

    How do big hosting companies like EUKHOST have it then, they must have gobal write?
     
  6. Mark_NL

    Mark_NL New Member

    big hosting companies? well it's basic stuff ..

    you log in onto your servers through ftp user/pass ..

    user logged in, uploads a file .. automatically it's owner is user and group the group the user is in .. after that, if you want that file to be writable through the webserver, you need to change it's file permissions MANUALLY ..

    If i know you are hosting a server with everything world writable, i'd like to hire a hosting package with you and have some fun! ;) .. if you know what i mean ... it's just a "not done" thing.

    if you want a file world write then do chmod o+w <file> and you should be fine
     
  7. Rapid2214

    Rapid2214 New Member

    Good Point...

    Thanks for the help.

    Marty
     

Share This Page