| はじめての自宅サーバ構築 - Fedora/CentOS - | Last Update | 2008/05/16 | |
| It opened to 2004/09/19. 当サイトはFedora9で運用しています |
Visitors Pageviews Today(IP/PV) |
3,250,875 11,998,791 1,344/7,448 |
|
デルではおとくなキャンペーン実施中! |
レノボ Web 広告限定ストア(キャンペーン&新着情報) |
設定ファイルの編集
# vi /etc/httpd/conf/httpd.conf
ドキュメントルートの指定(ここから)
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
Options Includes ExecCGI FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
.htaccessの許可
AllowOverride All
</Directory>
ドキュメントルートの指定(ここまで)
|
設定ファイル変更を有効にする為、apacheを再起動 # /etc/rc.d/init.d/httpd restart httpdを停止中: [ OK ] httpd を起動中: [ OK ] |
外部からアクセスできないパスへパスを作成する。 # mkdir /var/www/secure/ アクセス可能なユーザ名"linux"を作成する # htpasswd -c /var/www/secure/.htpasswd linux アクセス可能なユーザ名"linux"のパスワードを入力する New password: 確認の為、上記と同じパスワードを入力する Re-type new password: Adding password for user linux # パスワードファイル作成の確認 # ls -la /var/www/secure/.htpasswd -rw-r--r-- 1 root root 20 2月 10 12:38 /var/www/secure/.htpasswd |
アクセス可能なユーザ名"fedora"を追加する # htpasswd /var/www/secure/.htpasswd fedora アクセス可能なユーザ名"fedora"のパスワードを入力する New password: 確認の為、上記と同じパスワードを入力する Re-type new password: Adding password for user fedora |
アクセス制限をかけたいパスを作成する(既存の場合はそのパス内に作成する)
# mkdir /var/www/html/security/
apacheプロセスがアクセスできる権限にする。(ディレクトリ作成時のデフォルトは「755」となっているので特に必要はありません。)
# chmod 755 /var/www/html/security/
所有者:グループをapacheに変更。(最低限、所有者はapacheにすること。読み取りだけでは問題ないが書き込みがある場合エラーとなる為)
# chown apache:apache /var/www/html/security/
※:上記「chmod」と「chown」について、当該動作検証のみであれば、必要ありません。
今後、アクセス制限をかけたパスにて「書き込み」を行うスクリプトを設置する場合は必須となる。
.htaccessファイルを作成する
# vi /var/www/html/security/.htaccess
AuthUserFile /var/www/secure/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your UserName and password"
AuthType Basic
require valid-user
確認用のページを作成する
# vi /var/www/html/security/index.html
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<title>認証確認</title>
</head>
<body>
認証が成立しページが表示されました。
</body>
</html>
|

