Apache设置用户名和密码登录,apache用户名登录


1.安装的是Apache 2.4版本

2.找到httpd.conf文件夹,将SRVROOT改为对应路径

#Define SRVROOT "/Apache24"

Define SRVROOT "C:\Program Files (x86)\Apache24"

ServerRoot "${SRVROOT}"

3.找到httpd.conf文件夹中,.htaccess地方,将AllowOverride None改为AllowOverride All

  # 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
    #

    AllowOverride All

4.想将htdocs目录下的设置权限,所以在此目录下创建.htaccess文件

AuthName "user,password"
AuthUserFile "C:\Program Files (x86)\Apache24\bin\.htpasswd"(.htpasswd文件存放位置)
AuthType Basic

require valid-user admin

5.在命令提示符中进入安装的apache bin目录下,生成.htpasswd文件,输入相应的密码

htpasswd -c .htpasswd admin

6.重启apache,就需要使用 admin/密码 登录

7.不知道为什么当不使用.htaccess文件,直接在httpd.conf中添加认证不行,以后再看吧

相关内容

    暂无相关文章