Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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>
   ServerAdmin admin@mywebsite.com
   DocumentRoot "/home/my_user/public_html"
   ServerName mywebsite.com
   ServerAlias www.mywebsite.com
   ErrorLog "/var/log/httpd/mywebsite/error_log"
   CustomLog "/var/log/httpd/mywebsite/access_log" common
</VirtualHost>

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: http://stackoverflow.com/questions/14427808/you-dont-have-permission-error-in-apache-in-centos

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

1 Answer 1

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 http://example.com/~user/ 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

 
discard

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.