File permissions

The UNIX commands chmod and chown define the file permissions, i.e. who can access your files in what way.
Read this if you're getting Permission Denied on your website.

Introduction

Both commands have a man page: try man chmod and man chown for documentation.
There are three access modes:

  • r: read (for directories: list)
  • w: write (for directories: add/remove files)
  • x: execute (for directories: browse)

There are also three access groups:

  • user (u): yourself
  • group (g): any other user with a personal account
  • other (o): all other users (including system services)

Home Directory

You probably don't want anyone to read/write/delete your files. In that case you type

chmod go-rw ~

~ is an alias for your home directory.

It is important that the webserver (which runs as user www-data (uid 33) and thus falls under the group 'others') has browse access to your home. Therefor, your home directory must be executable:

chmod o+x ~

Dont worry, this will not make your home readable.

Files and Directories

If you gave no-one access to your home directory (not even execute), your files will be inaccessible for everybody (including the webserver). If you only made it executable, other people wont be able see what's in you home directory. However, if they know what's in there (like the webserver knows the www directory) and it is readable/writable for the 'others' group, they will be able to read/write it.