Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a directory apache readable on ubuntu

Following problem:

I have an ubuntu 12.04 server I made a virtual host with

DocumentRoot /var/www/

Everything is fine, I see the correct index.html when I point with webrowser to the website of this virtual host. When I look to the owner of the www folder I see:

ls -l
drwxr-xr-x  2 root root 4096 Jul 10 09:07 www

Now I change the DocumentRoot to

DocumentRoot /root/testFolder/

I copy my index.html in this folder, point with webrowser to my domain, then I get the message "You don't have the permission..."

Ok, I check the owner of testFolder

ls -l
drwxr-xr-x 2 root     root     4096 Jul 11 08:18 testFolder

It is the same as www folder.

Ok my next try to change the group owner of testFolder

chown -R www-data:www-data /root/testFolder/

But I get the same result in my browser: "You don't have permission to access / on this server."

like image 845
alisia123 Avatar asked Jul 11 '12 08:07

alisia123


People also ask

How do I make a directory writable in Apache?

Usually this user is named apache or www-data . So, in order to make a directory writable by the webserver we have to set the directory's owner or group to Apache's owner or group and enable the write permission for it.

How do I access Apache directory?

Well if you to want to allow /thumbs/ directories, it depends how they are being blocked in the first place. If they're blocked with normal Apache access permissions, then something like this will do it, but must go in the main server config at root level or in a <VirtualHost> and not in a . htaccess file.


1 Answers

Try:

chown -R apache:apache /root/testFolder/

and

chmod +r /root/testFolder

UPDATE
The solution in this specific case was to move apache from under /root into a folder that doesn't require root privileges.

like image 109
Nir Alfasi Avatar answered Nov 04 '22 18:11

Nir Alfasi