Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置apache2访问某个目录需要验证授权 #6

Open
leon0625 opened this issue Jan 16, 2018 · 0 comments
Open

配置apache2访问某个目录需要验证授权 #6

leon0625 opened this issue Jan 16, 2018 · 0 comments

Comments

@leon0625
Copy link
Owner

  1. 修改/etc/apache2/apache2.conf, 添加如下语句
<Directory /var/www/auth_test>
    Options Indexes 
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
</Directory>
  1. 在auth_test目录添加.htaccess文件,内容如下
AuthName "sys"
AuthType Basic
AuthUserFile /var/www/auth_test/.htpasswd
require user leon

第一行无关紧要,在某些浏览器会显示这个
第四行为登录的用户名

  1. 使用htpasswd命令生成密码文件
htpasswd -c /var/www/auth_test/.htpasswd leon

注意:这个密码文件命名要和第二步的配置名字一样

  1. 重启apache2
/etc/init.d/apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant