I am running Ubuntu with Apache (LAMP stack). When I changed the webroot from /var/www to /media/data/www, I keep getting 403 Forbidden even after chmod-ing the directory + files to 777. What did I do wrong? Also referencing /var/www, I noticed that the directory + files are owned by root should that be the case? Shouldn't it be www-root? Also if its root, will apache not be able to access it?

I noticed that I am getting errors like

[Wed May 11 11:53:40 2011] [crit] [client] (13)Permission denied: /media/data/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

but thing is, my web root is /media/data/jm/www

1 Answer 1


Ouch, please avoid chmod 777, it's like having your door open with the key in the lock.

Error 13 is related to permission errors. In Linux, a folder needs a execute-bit to allow descending in it. So, make sure the permissions on /media/data and /media/data/jm is set to 755 OR 700 if the user running apache is the owner of the folders.

root is the god in Linux systems, you've presumably run the chmod command using sudo (super-user do ...). The apache process just needs to be able to read the files (and write if you're using a dynamic language which needs to write to a cache for example). In Ubuntu, this user is www-data (not www-root).

To restore the permissions and make Apache own the files, run:

 sudo chown -R www-data /media/data/jm/www
 sudo find /media/data/jm/www -type f -exec chmod 600 {} \;
 sudo find /media/data/jm/www -type d -exec chmod 700 {} \;

The first command changes the ownership to www-data, the second changes file permissions to 600 (read-write for owner) and the third 700 for directories.

/media/data sounds like you've created a second partition. Make sure the filesystem support Linux file permissions. Ext2, ext3 and ext4 do. NTFS and FAT32 do not. You can check that by running sudo file -s $(readlink -f /dev/disk/by-label/data).

  • I found that I also needed to set permissions on the parent folder, in this case /media/data
    – JM at Work
    Commented May 12, 2011 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.