Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently created some linux users on my machine and their respective directories were created in the following manner /home/my_user so I decided to treat each user as one of my websites.

I moved all my website files over to this directory like so /home/my_user/public_html/.

I edited the virtual host in my httpd.conf and changed the root directory folder so this is how that looks

<VirtualHost *:80>
   DocumentRoot "/home/my_user/public_html"
   ErrorLog "/var/log/httpd/mywebsite/error_log"
   CustomLog "/var/log/httpd/mywebsite/access_log" common

Now this virtual host configuration was working perfectly fine with my older document root path that was located at /var/www/html/mywebsite/public_html but after changing that to what it is right now, I am getting a permission denied error.

But I followed the instructions here:

Even after following the above instructions, when I run the following command: sudo -u apache ls /home/my_user/public_html

The server responds with

ls: cannot open directory /home/my_user/public_html: Permission denied

Even so, I do not get a permissions denied error when I try to access my site any more, however, now I am redirected to the default page of apache instead of my website.

I am not exactly sure what's wrong any more, if anyone has an idea, it would be great if you guys could help out!

share|improve this question
What are the permissions on /home/my_user/public_html? What does the access log and error logs say when you try access the site? – Marcus Oct 27 '13 at 6:14
The permissions for public_html there is rwxrwx--- or 077 further more error logs and access logs simply say that access was denied that's all.\ – Maaz Oct 27 '13 at 6:19
If you're using Centos, is SElinux enforced? Run 'getenforce' – Marcus Oct 27 '13 at 6:20
command returns Disabled – Maaz Oct 27 '13 at 6:25
Also, what are the permissions for /home/my_user? On some distros such as Redhat/Centos it's 700 so the group won't have access to it. – Marcus Oct 27 '13 at 6:26

I would use mod_userdir if I were you to configure a public_html dir in each of your users homedir.

This module allows user-specific directories to be accessed using the syntax.

You can enable it for only a subset of users if you'd like:

UserDir disabled
UserDir enabled user1 user2 user3 

With this in place you will probably have more luck with the perms, as it might very well be that with your conf, you're getting an SELinux denial or something on top of your permission errors.

You typically don't want to allow other users access to the users directories, which your approach would require.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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