CentOS serving home directory with Apache

19, Jul 2012

Contents

If you want to setup CentOS to allow Apache to serve out the user home directories there's a couple of quick settings that need to be changed.

First, edit /etc/httpd/conf/httpd.conf, and find the section that begins:

<IfModule mod_userdir.c>

Comment out UserDir disabled, and uncomment the line saying UserDir public_html.

Then, restart httpd, and change one of the SeLinux booleans:

service httpd restart
setsebool httpd_read_user_content on

The final thing to make sure of is that the /home/username folder is world executable, and make the public_html folder:

chmod a+x ~/
mkdir ~/public_html
echo "Hello World" > ~/public_html/index.html

That's it! Go load your website and rejoice.

Comments

Pierros Papadeas said on Sep 14, 2012:

Nice post and thanks for the info :) One point though: You need to make sure to get permissions right.

The user directory needs to be 711 and the public_html folder 755.

Cheers!

Have Something to Say?

Questions? Comments? Concerns? Let me know what you’re thinking.

  • You can use Markdown formatting here.