2011年6月29日水曜日

ユーザごとの公開ディレクトリを作りたい

前回、DocumentRoot以外のディレクトリを公開したい を紹介しましたが、別の方法で公開用ディレクトリを作成することもできます。
サーバを管理していく上で、ユーザの数が増えてきたとき、公開用ファイルが1つだけ、というのは現実的でありません。
各々ユーザに公開用ファイルを配置するディレクトリを用意します。

具体例
ホスト名:hoge.com
ユーザ:shindo_t

手順
① httpd.confの設定に赤字を追加します。
(ユーザshindo_t にだけ公開用ディレクトリを用意する場合)
UserDir disabled
UserDir enabled shindo_t
UserDir public_html

② ディレクトリを作成
[shindo_t@hoge ~]$ mkdir ~/public_html

③ 権限の設定
[shindo_t@hoge ~]$ chmod 701 ~/public_html

これで完成です。
shindo_t ホームディレクトリにある pubilc_html/test.html にアクセスしたいときは、下記のURLを入力します。
http://hoge.com/~shindo_t/test.html


*あるユーザ(yamada_t)だけ公開ディレクトリを禁止することもできます。
上記の手順①で、下記の設定とすれば良いです。
UserDir enabled
UserDir disabled yamada_t
UserDir public_html

*各々環境
Linuxでは、公開ファイルは、public_htmlがデフォルトであることが多いです。
Windowsでは、My Documents¥My Website がデフォルトであることが多いです。
Windowsだと、②の作業はExploreで新規フォルダ "My Website" を作成すればよいです。③は必要ないです。

0 件のコメント:

コメントを投稿