为了安全起见,部署的web内容不想让别人看到,或者为了增强安全性。

部署步骤:

  1. 首先利用apache的htpasswd功能生成一个用户名和密码:

htpasswd -c /usr/local/nginx/conf/test.pass testNew password:123456

2.在nginx配置文件location中添加如下两行:

location / {            root   /usr/share;            index  index.php index.html index.htm;            auth_basic "Authorized users only";            auth_basic_user_file conf/test.pass;        }