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

I'm just trying to make a public_html folder under my username on a Red Hat Linux Server (and it's all been a bit of a headache).

I made the folder and set the permissions to 755.
I wasn't sure how to deal with Apache (and admittedly finding the httpd.conf file was a nightmare, thanks to an unconventional directory layout), but now I've found it, I'm not sure what to do.

I've seen this question; Setting up individually accessible public_html for each user of a linux machine, but I don't understand the answer. How can I 'use mod_userdir' (I'm quite new to all of this).

I've looked at this;
http://httpd.apache.org/docs/2.0/mod/mod_userdir.html

Am I supposed to append something for the 'httpd..conf file?

I tried appending 'UserDir enabled username' to the top, and restart Apache, but still I can't find a page at;
domain.com/~username/

What could the problem be?
Am I using mod_userdir incorrectly? (I don't even know HOW to use it)

Thanks!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

What RedHat version do you have installed? On RedHat 6.x it's pretty straightforward:

1) let's assume I have a user ec2-user created with home directory /home/ec2-user

2) create a directory /home/ec2-user/public_html and make sure that directory /home/ec2-user and /home/ec2-user/public_html have set permissions at least 0711 (executable bit set on other means that apache user under which apache2 web server is running will have permission to enter these directories). Additionally, any content of that directory has to be readable by the apache user.

3) enable UserDir module in apache2 web server configuration which is available in the file /etc/httpd/conf/httpd.conf. Comment out the line UserDir disabled and uncomment the line UserDir public_html:

<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    #UserDir disabled

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    #
    UserDir public_html

</IfModule>

4) test apache2 web server configuration with httpd -t, it should return Syntax OK otherwise something went wrong

5) restart apache2 web server with service httpd restart and optionally, enable the service with chkconfig httpd on on boot

6) finally, if you have selinux enabled in enforcing mode - you can check it with sestatus - you have to run this command setsebool -P httpd_read_user_content=on to allow apache2 web server to read user content

7) test it, e.g. from the server run w3m http://localhost/~ec2-user, if there are any errors they should be logged to the log file /var/log/httpd/error_log

share|improve this answer
    
I hadn't commented out 'UserDir disabled'; you're a lifesaver! :) (Why is that instruction so difficult to find?! –  Anti Earth Sep 25 '13 at 6:36
    
@Anti-Earth Once you gain some experience, you will find it logical to search configuration files (to check for things like pre-existing values or useful comments). Red Hat documents many beginner details like this in their docs and if you have a subscription, in their paid knowledge base. –  evilensky Sep 25 '13 at 15:18

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.