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中添加認證不行,以後再看吧

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章