PHP Permissions

by Kevin Partner on 29th February, 2008

When you upload a file using PHP, you’ll usually want to use move_uploaded_file to move the file into a folder of your choice. The problem is that you’ll struggle with this unless PHP has permission to write to the folder.

The important thing to remember is that PHP inherits Apache’s user group on a Linux system. To find out which group Apache belongs to, you need to find a file called /etc/passwd, open it up (or copy it to your PC and open it in Notepad) and you’ll find a line begining with “apache”. There’s 2 sets of numbers in this line and you want the second. This is the group id.

Now you need to change the group owner of the upload folder to this number and PHP will be able to write to it without you having to give public access to it. You can do this using, for example, the excellent Bitvise Tunnelier.

Share and Enjoy:
  • Print
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Technorati
  • Add to favorites

Leave a Comment

Previous post:

Next post: