Apache用户登陆验证

1.  编辑配置文件vi /usr/local/apache/conf/httpd.conf
AllowOverride AuthConfig

2.  创建用户目录
mkdir /usr/local/apache/htdocs/ftp

3.        添加2个用户
# htpasswd -c /usr/local/apache/passwd/passwords admin
New password: mypassword
Re-type new password: mypassword
Adding password for user admin             注:添加第2个用户不需要参数 -C
# htpasswd /usr/local/apache/passwd/passwords test

4.     编辑控制文件 vi /usr/local/apache/htdocs/ftp/.htaccess
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user

发表评论

电子邮件地址不会被公开。 必填项已用*标注