一般ユーザーにホームページスペースを提供できるようにする。
ここでは、ホームページスペース提供サービスを行っている一般的なWebサーバーと同様な、http://sudachi.jp/~ユーザー名/というURLで、一般ユーザーが作成したホームページへアクセスできるようにする。
目次 |
[root@host3 ~]# vi /etc/httpd/conf/httpd.conf ← httpd設定ファイル編集
<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
↓
#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
↓
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>
以下の全行追加
<Directory /home/*/public_html>
AllowOverride All ← .htaccessの許可
Options IncludesNoExec ExecCGI FollowSymLinks ← CGI,SSI(Exec命令以外)の許可
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
[root@host3 ~]# /etc/rc.d/init.d/httpd restart ← httpd設定反映 httpd を停止中: [ OK ] httpd を起動中: [ OK ]
既存ユーザーの場合、スクリプトで一括してユーザーディレクトリを作成する
[root@host3 ~]# vi userdirmake ← ユーザーディレクトリ一括作成スクリプト作成
#!/bin/bash
for user in `ls /home`
do
id $user > /dev/null 2>&1
if [ $? -eq 0 ] && [ ! -d /home/$user/public_html ]; then
mkdir -p /home/$user/public_html
chown $user. /home/$user/public_html
chmod 711 /home/$user
echo $user
fi
done
[root@host3 ~]# sh userdirmake ← ユーザーディレクトリ一括作成スクリプト実行
user1
・
・
usern
[root@host3 ~]# rm -f userdirmake ← ユーザーディレクトリ一括作成スクリプト削除
新規ユーザー追加時にユーザーディレクトリ(~/public_htmlディレクトリ)が自動で作成されるようにする
[root@host3 ~]# mkdir /etc/skel/public_html ← ユーザー追加時に~/public_htmlディレクトリが自動で作成されるようにする
SSHによるリモート接続もできるようにする
※例としてユーザ名をsudachiとする
[root@host3 ~]# useradd sudachi ← 一般ユーザー追加 [root@host3 ~]# passwd sudachi ← 一般ユーザーパスワード設定 ユーザー sudachi のパスワードを変更。 新しいパスワード: ← 一般ユーザーパスワード応答 新しいパスワードを再入力してください: ← 一般ユーザーパスワード応答(確認) passwd: 全ての認証トークンが正しく更新できました。 [root@centos ~]# chmod 711 /home/sudachi/ ← 一般ユーザーのホームディレクトリのパーミッション変更