やりたい事とか ・RAID ・LPIC-201 ・自転車を買う(買っちゃった~) ・サイト作成

2009年8月21日金曜日

UserDirの設定

UserDirで超はまった。

つぼに来たわけではないのだ。
わからなくて、罠から抜け出せなかったのだ。

二度とそうならないように、手順を残す。


環境:CentOS5.3。Apache2.2.3-22.el5
今回は「hoge」というユーザの場所(/home/hoge)でやるとします。
基本はrootユーザで作業をしていきます。



0.基本として、hogeユーザを追加しておくこと。パーミッションも変更。
useradd hoge
passwd hoge
chmod 711 /homge/hoge



1./home/hogeにpublic_htmlディレクトリを作成する。
su hoge
mkdir /home/hoge/public_html
exit






2./home/hoge/public_htmlに、index.htmlを作成
vi /home/hoge/public_html/index.html
#index.htmlの中は適当に。







3.httpd.confを編集
vi /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 disabled              ←☆この部分をコメントアウト
UserDir enabled hoge             ←☆この部分を追加

#
# 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>                    ←☆ここまで新規に追加








4.httpdをrestart
service httpd restart







5.ブラウザから確認。下記のアドレスをブラウザに打ち込めば、あなたが用意した/home/hoge/public_html/index.htmlが表示されるはず。
http://サーバのIP/~hoge/








6.アクセスできなければ、/var/log/httpd/error_logを確認


・File does not exist /var/www/html/hoge が出ていたら、そもそも根本的になにか間違っている
・(13)Permission denied: access to /~negishi hoge の場合、7以降を行ってみる必要がある。










7./home/hoge/パーミッションの確認する。
その他のユーザに
ディレクトリだと、実行権限、
index.htmlだと読み取り権限が必要。

#要はこんな感じなんだわ。
/home          ←drwxr-xr-x
/home/hoge         ←drwx--x--x
/home/hoge/httpd      ←drwx--x--x
/home/hoge/httpd/error_log ←drwxr--r--


問題なさそうなら、ブラウザで確認。





7.それでも表示されない場合。SELinuxの停止
system-config-securitylevel-tui
SELinux:Enforceing
    Permissive
    無効       ←選択


それでもう一回ブラウザで確認してみて。




7.それでも表示されない場合。下記の秘密の呪文を唱える。(SELinux関連のコマンド)
fixfiles restore



もう一回確認してみて。




それでもダメなら、私にはわからん。

0 件のコメント:

コメントを投稿

フォロワー

ブログ アーカイブ