カテゴリ:

まぁとりあえずApacheはさっくり動くだろうから書くことないと思いつつ、とりあえずDocumentRootだけをユーザのホームディレクトリのhtdocsに変更しておく。

とりあえずindex.htmlを作って開こうとすると、エラー(Forbidden)。

# tail /var/log/httpd/error_log
[Tue Dec 13 15:45:50 2005] [error] [client 192.168.0.194] (13)Permission denied: access to /index.html denied

あれ、ミスするところではないはずだが。ディレクトリのパーミッションかと思い見てみるも問題なし。ここでふと思い出す、そうそれはSELinux。

# ls -ldZ /var/www/html /home/john/htdocs
drwxr-xr-x  john     beatles  user_u:object_r:user_home_t      /home/john/htdocs
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_content_t /var/www/html

上2つのディレクトリは確かにセキュリティコンテキストが異なっていますね。これによりSELinuxではねられたのです。

chconコマンドで修正します。

# chcon root:object_r:httpd_sys_content_t  htdocs
# chcon root:object_r:httpd_sys_content_t  htdocs/index.html

これで無事htmlファイルが開くようになりました。しかし初めてやる人には大変な作業だよね〜。ちなみにcgi-binディレクトリはまた別の指定です。

# ls -ldZ /var/www/cgi-bin
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_script_exec_t /var/www/cgi-bin