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