{"id":103699,"date":"2024-09-06T02:46:10","date_gmt":"2024-09-05T18:46:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=103699"},"modified":"2024-09-06T02:46:10","modified_gmt":"2024-09-05T18:46:10","slug":"apache-htaccess","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/apache-htaccess.html","title":{"rendered":"\u5229\u7528.htaccess\u6587\u4ef6\u4fdd\u62a4\u7f51\u7ad9\u76ee\u5f55\u9690\u79c1"},"content":{"rendered":"
\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u5404\u79cd\u5404\u6837\u7684\u7f51\u7ad9\u76ee\u5f55\u9650\u5236\u573a\u666f\u975e\u5e38\u4e4b\u591a\uff0c\u8fd9\u65f6\u5c31\u53ef\u80fd\u9700\u8981\u7528\u5230Apache htpasswd\u5de5\u5177\u6765\u5b9e\u73b0\u3002<\/p>\n
<\/p>\n
\u5148\u4f7f\u7528Apache htpasswd\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u5bc6\u7801\u6587\u4ef6\uff0chtpasswd\u7684\u547d\u4ee4\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n
\r\n-c # \u521b\u5efa\u5bc6\u7801\u6587\u4ef6\uff0c\u82e5\u8be5\u6587\u4ef6\u5df2\u5b58\u5728\uff0c\u5b83\u4f1a\u91cd\u5199\u5e76\u5220\u9664\u539f\u6709\u5185\u5bb9\uff1b\r\n-n # \u4e0d\u66f4\u65b0\u5bc6\u7801\u6587\u4ef6\uff0c\u76f4\u63a5\u663e\u793a\u5bc6\u7801\uff1b\r\n-m # \u4f7f\u7528MD5\u52a0\u5bc6\uff08\u9ed8\u8ba4\uff09\uff1b\r\n-d # \u4f7f\u7528CRYPT\u52a0\u5bc6\uff08\u9ed8\u8ba4\uff09\uff1b\r\n-p # \u4f7f\u7528\u666e\u901a\u6587\u672c\u683c\u5f0f\u7684\u5bc6\u7801\uff1b\r\n-s # \u4f7f\u7528SHA\u52a0\u5bc6\uff1b\r\n-b # \u547d\u4ee4\u884c\u4e2d\u4e00\u5e76\u8f93\u5165\u7528\u6237\u548c\u5bc6\u7801\uff0c\u800c\u4ea4\u4e92\u6027\uff0c\u751f\u6210\u65f6\u53ef\u89c1\u5bc6\u7801\u660e\u6587\uff1b\r\n-D # \u5220\u9664\u6307\u5b9a\u7684\u7528\u6237\uff1b\r\n<\/pre>\n\u521b\u5efa\u6dfb\u52a0\u4e00\u4e2a\u7528\u6237\u540d\u4e3a\uff1arenwole \u5bc6\u7801\u4e3a\uff1arenwole \u7684\u5bc6\u7801\u6587\u4ef6\uff1a<\/p>\n
\r\n$ htpasswd -c .accpasswd renwole\r\nNew password:\r\nRe-type new password:\r\nAdding password for user renwole\r\n<\/pre>\n\u6ce8\u610f\uff1a\u521b\u5efa\u7684\u5bc6\u7801 .accpasswd \u6587\u4ef6\u540d\u53ef\u81ea\u5b9a\u4e49\u3002<\/p>\n
\u4f7f\u7528cat\u67e5\u770b\u751f\u6210\u7684\u5185\u5bb9\uff1a<\/p>\n
\r\n$ cat .accpasswd\r\nrenwole:$apr1$4owQhqtn$ElCDIh0sfR.ZFzeaY9sDw0\r\n<\/pre>\n\u6ce8\u610f\uff1a\u751f\u6210\u7684\u5bc6\u7801\u662f\u5df2\u7ecf\u52a0\u5bc6\u8fc7\u7684\uff0c\u6240\u4ee5\u522b\u5f04\u6df7\u6389\u4e86\u3002<\/p>\n
\u6dfb\u52a0\u591a\u4e2a\u8d26\u53f7\uff1a<\/p>\n
\r\n$ htpasswd -b .accpasswd renwolecom password-renwolecom\r\nAdding password for user renwolecom\r\n<\/pre>\n\u67e5\u770b\u751f\u6210\u7684\u591a\u4e2a\u8d26\u53f7\u548c\u5bc6\u7801\uff1a<\/p>\n
\r\n$ cat .accpasswd\r\nrenwole:$apr1$4owQhqtn$ElCDIh0sfR.ZFzeaY9sDw0\r\nrenwolecom:$apr1$3zzGmKtR$jKKCbU2nVEQZFz9mtEXE.\/\r\n<\/pre>\n\u5220\u9664\u7528\u6237:<\/p>\n
\r\n$ htpasswd -D .accpasswd renwolecom\r\nDeleting password for user renwolecom\r\n<\/pre>\n\u67e5\u770b\u5220\u9664\u540e\u7684\u5bc6\u7801\u6587\u4ef6\uff1a<\/p>\n
\r\n$ cat .accpasswd\r\nrenwole:$apr1$4owQhqtn$ElCDIh0sfR.ZFzeaY9sDw0\r\n<\/pre>\n\u521b\u5efa\u5bc6\u7801\u4fdd\u62a4\u533a\u57df<\/p>\n
\u6709\u4e86\u5bc6\u7801\u6587\u4ef6\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528.htaccess\u6587\u4ef6\u521b\u5efa\u4fdd\u62a4\u533a\u57df\u3002<\/p>\n
\u5c06\u4ee5\u4e0b\u5185\u5bb9\u4fdd\u5b58\u4e3a .htaccess \u6587\u4ef6\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u8be5\u6587\u4ef6\u5efa\u7acb\u4fdd\u62a4\u533a\u57df\u3002<\/p>\n
\r\n$ vim \/apps\/web\/renwolecom\/phpMyadmin\/.htaccess\r\n\r\nAuthType Basic\r\nAuthName \"restricted area\"\r\nAuthUserFile \/usr\/local\/apache\/conf\/.accpasswd\r\nrequire valid-user\r\n<\/pre>\n\u5c06\u8be5\u6587\u4ef6\u653e\u5728\u9700\u8981\u4fdd\u62a4\u7684\u76ee\u5f55\u4e0b\u5373\u53ef\u3002\u56e0\u6b64\u6211\u653e\u5728\u4e86\u7f51\u7ad9\u6839\u76ee\u5f55\u7684phpMyadmin\u76ee\u5f55\uff0c\u8fd9\u6837\u8bbf\u95ee\u6b64\u76ee\u5f55\uff0c\u5c31\u4f1a\u51fa\u73b0\u5f39\u7a97\u9a8c\u8bc1\uff0c\u8f93\u5165\u751f\u6210\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u5373\u53ef\u3002<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/renwole.com\/archives\/983<\/a><\/p>\n