nginx实现用户认证访问页面
2015-10-07 20:59
696 查看
安装apache支持的htpasswd
yum -y install httpd
安装完成后查看其路径
[localhost@root ~]$ which htpasswd
[localhost@root ~]$ /usr/bin/htpasswd
生成密码库文件
[root@acgcommittee xiangchen]# htpasswd -c /usr/local/nginx/conf/.htpassed acg
New password: #输入密码
Re-type new password: #再次输入密码
编辑/usr/local/nginx/config/nginx,conf或者nginx的虚拟主机配置文件
添加如下认证配置(示例)
location /
{
root /usr/local/http/admin.php;
auth_basic "Auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
}
检查nginx配置是否正确
/usr/local/nginx/sbin/nginx -t
yum卸载临时使用的httpd
yum -y remove httpd
yum -y install httpd
安装完成后查看其路径
[localhost@root ~]$ which htpasswd
[localhost@root ~]$ /usr/bin/htpasswd
生成密码库文件
[root@acgcommittee xiangchen]# htpasswd -c /usr/local/nginx/conf/.htpassed acg
New password: #输入密码
Re-type new password: #再次输入密码
编辑/usr/local/nginx/config/nginx,conf或者nginx的虚拟主机配置文件
添加如下认证配置(示例)
location /
{
root /usr/local/http/admin.php;
auth_basic "Auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
}
检查nginx配置是否正确
/usr/local/nginx/sbin/nginx -t
yum卸载临时使用的httpd
yum -y remove httpd
相关文章推荐
- nginx如何执行请求的
- linux/ubuntu下安装nginx时./configure后出现几种错误的解决方法
- centos7 nginx安装及配置端口转发实战
- Nginx的安装和配置
- Nginx+uWSGI+Django框架搭建
- nginx+gunicorn+bottle
- Nginx 配置高并发
- Nginx 教程
- Nginx中location配置[转]
- nginx动静分离后的一些小事故,给出处理方法
- nginx安装部署
- SEnginx安全相关模块配置说明
- Nginx 引入线程池
- 用nginx图片缓存服务器
- Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 在 CentOS 下的编译安装
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]
- nginScript笔记
- SEnginx安全相关模块配置
- nginx缓存批量清除
- ubuntu+nginx+supervisor部署tornado