Mobile app version of vmapp.org
Login or Join
Gail5422790

: Getting 403 Forbidden after changing webroot 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

@Gail5422790

Posted in: #403Forbidden #Apache #Chmod #Lamp #Ubuntu

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 127.0.0.1] (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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Hamm4606531

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).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme