LNMP下目录访问验证
?1、創建類htpasswd文件
?
#wget -c soft.vpser.net/lnmp/ext/htpasswd.sh;bash htpasswd.sh
按提示輸入:
用戶名:test
密碼:test
文件名:/usr/local/nginx/conf/access.conf
腳本會自動生成認證文件,access.conf內容如下:
#cat?/usr/local/nginx/conf/access.conf
test:pwTiMmoH21rbs
2、為Nginx添加auth認證配置
下面以某域名下面的auth目錄為例,在域名的server段里加上如下代碼:
location ^~ /auth/?{
location ~ .*\.(php|php5)?$?{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
auth_basic "Authorized users only";
auth_basic_user_file?/usr/local/nginx/conf/access.conf
}
auth_basic_user_file 為htpasswd文件的路徑
重啟nginx,訪問http://yourdomainname/auth/ 就會提示輸入用戶名和密碼。
轉載于:https://blog.51cto.com/3619523/1118165
總結
以上是生活随笔為你收集整理的LNMP下目录访问验证的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ecos移植准备
- 下一篇: 【转】软件工程师的年终总结2