This is just a quick minidump for myself, but may be interesting for other Linux or Fedora newbies as well. Today I wanted to enable the UserDir feature of my local web server for a quick demo of a small webapp. I already knew the UserDir feature and hence was thinking that it’s just a 5 minute “quick sudo” task. Poor me it wasn’t the case.
UserDirs The Fedora Way
First of all, on Fedora 15, you don’t edit /etc/httpd/conf/httpd.conf, although you could go for it. Instead, you extend your initial (base) configuration with little configuration snippets located in /etc/httpd/conf.d/. To follow this convention, a simple userdir.conf file in previously mentioned directory should be created with the following content:
<IfModule mod_userdir.c>
UserDir enabled [user]
UserDir public_html
</IfModule>
<Directory /home/*/public_html>
Options Indexes Includes FollowSymLinks
AllowOverride All
Allow from all
Order deny,allow
</Directory>
Note that in above file [user] is a placeholder for the actual user (you might as well extend/change this for your purposes as well). Assuming that /home/[user]/public_html/ exists, one might think that a quick sudo service httpd restart should do it then. No it won’t. Navigating to the userdir URI just responds with a cold 403 permission denial.
“Alright”, me thinks. It’s time to pay attention to SELinux.
Tweaking SELinux Settings
The security configuration of SELinux on Fedora 15 is enabled by default (set to Enforcing). You might go for the easy way and disable SELinux completely. However, instead of breaking a fly on a wheel, I decided to go for the needle-haystack game and adjust SELinux settings.
First of all, ensure that the directories have proper permissions:
## home directory ##
sudo chmod 711 /home/[user]
## public_html directory ##
sudo chown [user]:[user] /home/[user]/public_html
sudo chmod 755 /home/[user]/public_html
Then, tweak SELinux settings for user directories and user content:
sudo setsebool -P httpd_enable_homedirs true
sudo setsebool -P httpd_read_user_content 1
Finally restart httpd. Voilà, c’est ça!