vim /usr/local/nginx/conf/vhosts/xrc.conf
加入:
location ~ .*admin\.php$ { ----匹配 admin 字符页面,如果是目录, location /xrc/
auth_basic "xrc auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd; ----定义密码文件
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name; ----配置php解析
}
创建htpasswd文件:
用httpd附带的工具,没有的话就yum install httpd,如果有安装的话就在/usr/local/apache/bin/htpasswd下
用法:
2.创建认证的用户密码:
htpasswd -c /usr/local/nginx/conf/.htpasswd user1 -------创建新用户user1
如果还要创建一个用户,直接:
htpasswd /usr/local/nginx/conf/.htpasswd user2 ---不需要-c选项,,不然会覆盖之前的user1
时间: 2024-10-27 17:54:24