close

3. Secure Directory and basic configuration

#cd /var/www/html
#mkdir secure

#cat > index.html <
> Secure page
> secure page
> ookk

(1)create .htaccess and .htpasswd
#vi /var/www/html/secure/.htaccess
AuthName "restricted stuff"
AuthType basic
AuthUserFile /etc/httpd/conf/.htpasswd
require valid-user

#htpasswd -cm /etc/httpd/conf/.htpasswd student
% c : create(只有在第一次使用)
% m: md5
#htpasswd -m /etc/httpd/conf/.htpasswd joe
#chgrp apache .htpasswd
#chmod 640 .htpasswd

(2) vi /etc/httpd/conf/httpd.conf
#edit (記要加"<", 因與html語法有重覆,故意不加"<")
Directory "/var/www/html/secure">
Options -Indexes
AllowOverride AuthConfig
/Directory>

(3) 重新啟動
#service httpd restart

http://server118.example.com/secure

就會提示要輸入username, password

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 aquatower 的頭像
    aquatower

    2006隨手札記

    aquatower 發表在 痞客邦 留言(0) 人氣()