Fedora 25
Sponsored Link

ユーザーのホーム領域を有効にする2016/12/08

 
一般ユーザーが自身のホームディレクトリ内に置いたファイルを Web サイトとして公開できるように設定します。
[1] UserDir を利用できるよう設定します。
[root@www ~]#
vi /etc/httpd/conf.d/userdir.conf
# 17行目:コメント化

#
UserDir disabled
# 24行目:行頭の#を削除してコメント解除

UserDir public_html
# 31行目 - 35行目

<Directory "/home/*/public_html">
    AllowOverride
All
   
# 変更

    Options
None
   
# 変更

    Require method GET POST OPTIONS
</Directory>
[root@www ~]#
systemctl restart httpd

[2] SELinux を有効にしている場合、ユーザーのホーム領域を有効にするにはポリシーの許可設定が必要です。
[root@www ~]#
dnf -y install checkpolicy policycoreutils-python-utils
[root@www ~]#
setsebool -P httpd_enable_homedirs on

[root@www ~]#
restorecon -R /home
[3] 任意の一般ユーザーでテストページを作成して動作確認をします。クライアントPC で Web ブラウザを起動し、以下のように作成したテストページにアクセスできれば OK です。
[fedora@www ~]$
mkdir public_html

[fedora@www ~]$
chmod 711 /home/fedora

[fedora@www ~]$
chmod 755 /home/fedora/public_html

[fedora@www ~]$
vi ./public_html/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
UserDir Test Page
</div>
</body>
</html>
関連コンテンツ