htpasswd生成包含用戶名和密碼的文本文件,
每行內容格式為“用戶名:密碼”,
用於用戶文件的基本身份認證。
當用戶瀏覽某些網頁的時候,
瀏覽器會提示輸入用戶名和密碼,
比如awstats的日志報表,
你肯定不希望別人也能訪問,
因此就需要對這些報表網頁的訪問增加身份驗證。
如果你的web服務器是apache的話,
那么應該會自帶htpasswd程序的,
不過我用的是nginx,
所以就需要安裝一下了
ubuntu的好處體現出來了,
輸入htpasswd,
系統會提示在哪個包中可以找到,
共查到5個包,
不是每個包都有htpasswd,
parallels@parallels-vm:~$ sudo apt search htpasswd Sorting... Done Full Text Search... Done apache2-utils/xenial-updates 2.4.18-2ubuntu3.9 amd64 Apache HTTP Server (utility programs for web servers) golang-github-abbot-go-http-auth-dev/xenial,xenial 0.0~git20150714.0.46b9627-1 all Basic and Digest HTTP Authentication for golang http libapache-htpasswd-perl/xenial,xenial 1.8-1.1 all Manage Unix crypt-style password file libauthen-htpasswd-perl/xenial,xenial 0.171-1 all Perl module to read and modify Apache .htpasswd files libcatalyst-authentication-store-htpasswd-perl/xenial,xenial 1.003-1 all Authen::Htpasswd based user storage/authentication lighttpd/xenial,now 1.4.35-4ubuntu2 amd64 [residual-config] fast webserver with minimal memory footprint
我們這里選apache2-utils。
parallels@parallels-vm:~$ sudo apt install apache2-utils
安裝完查詢確認有沒有包含
parallels@parallels-vm:~$ which htpasswd /usr/bin/htpasswd