How to make a directory apache readable on ubuntu

2019-04-28 20:00发布

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

1条回答
Root(大扎)
2楼-- · 2019-04-28 20:53

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.

查看更多
登录 后发表回答