shell > yum -y install httpd-tools # 安装 htpasswd 工具 shell > cd /usr/local/nginx-1.10.2/conf shell > htpasswd -c pass.db wang # 创建认证用户 wang 并输入密码,添加用户时输入 htpasswd pass.db username shell > vim /etc//conf.d/start.conf server { listen 80; server_name local.server.com; auth_basic "User Authentication"; auth_basic_user_file /usr/local/nginx-1.10.2/conf/pass.db; location / { root /data/www; index index.html; } }