apacheでユーザーホームページを公開できるようにするのですが、Fedora Core 3ではデフォルトでSELinuxが有効になっているため、いつものようにはいきません。
めんどっちぃのでRPMインストール
$ yum install httpd
apr、apr-util、httpd-suexecも同時にインストールされます。
例のごとく/etc/httpd/conf/httpd.confを編集
<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 disable
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
UserDir public_html
</IfModule>
・・・
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
apacheを起動してリーブート時にも自動的に起動するようにします。
$ /etc/init.d/httpd start
$ /sbin/chkconfig httpd on
試しにユーザーホームページを作ってみます。
$ chmod o+x /home/hide
$ mkdir /home/hide/public_html
$ vi /home/hide/public_html/index.html
・・・適当に書く
で、OKのはずですがブラウザからアクセスしてみると403 permission deniedが返ってアクセスできません。
/var/log/messagesをのぞくと
Jan 8 19:13:58 vm kernel: audit(1105179238.192:0): avc: denied { search } for pid=2767 exe=/usr/sbin/httpd name=public_html dev=dm-0 ino=1196159 scontext=root:system_r:httpd_t tcontext=user_u:object_r:user_home_t tclass=dir
Jan 8 19:13:58 vm kernel: audit(1105179238.200:0): avc: denied { getattr } for pid=2767 exe=/usr/sbin/httpd path=/home/hide/public_html dev=dm-0 ino=1196159 scontext=root:system_r:httpd_t tcontext=user_u:object_r:user_home_t tclass=dir
どうもSELinuxが影響してるっぽいのでここを参照に以下のようにするとOK。
$ ls -adZ public_html
drwxrwxr-x hide hide user_u:object_r:user_home_t public_html/
$ chcon -t httpd_sys_content_t public_html
$ ls -adZ public_html
drwxrwxr-x hide hide user_u:object_r:httpd_sys_content_t public_html/