2007年8月1日水曜日

各ユーザ別にWebページを公開する場合の設定

httpサーバにはapacheを使っています。
通常はhttpd.confの中でDocumentRootで指定したディレクトリにドキュメント(HTMLファイル等)を配置します。

http://ドメイン名/index.html

のURLの場合、index.htmlは、このDocumentRootで指定したディレクトリにあるindex.htmlのことです。

このほかに、登録ユーザごとに、独立したDocumentRootを指定することも可能です。

Fedora7では、httpd.confは、以下の場所にあります。

/etc/httpd/conf/httpd.conf


httpd.confファイルの場所はディストリビューションやインストール方法によって異なります。

/etc/httpd/conf/      : Fedora CoreなどRed Hat系
/etc/apache2/        : SUSE系
/usr/local/apache2/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セクションのコメントをはずして、AllowOverride, Optionsは以下のように変更します。


<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
AllowOverride FileInfo None
Options SymLinksIfOwnerMatch
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>


各ユーザごとに、以下の処理を行います。

・homeディレクトリにpublic_htmlディレクトリを作成する。
・public_htmlディレクトリに読み込み権限、実行権限を付与します。
・ホームディレクトリは実行権限を付与します。
・SELinuxの制限を解除するために、ラベルを変更します。

/home/ishii を例書くと、以下のようになります。


[ishii@fedora7 ~]$ pwd
/home/ishii
[ishii@fedora7 ~]$ mkdir public_html
[ishii@fedora7 ~]$ chmod o+rw public_html/
[ishii@fedora7 ~]$ chmod o+x ./
[ishii@fedora7 ~]$ /sbin/restorecon -R public_html/

0 件のコメント: