centos 7.6 安装配置nginx (显示中文目录,带密码验证)
yum install -y nginx
service nginx start
配置文件重新生效
nginx -s reload
配置文件所在目录
vim /etc/nginx/nginx.conf
38 server { 39 listen 80 default_server; 40 listen [::]:80 default_server; 41 server_name _; 42 # root /usr/share/nginx/html; 43 44 # Load configuration files for the default server block. 45 include /etc/nginx/default.d/*.conf; 46 charset utf-8,gbk; 47 48 location / { 49 root /home/user/public; 50 autoindex on; 51 autoindex_exact_size off; 52 autoindex_localtime on; 53 auth_basic "secret"; 54 auth_basic_user_file /home/nginx/passwd.db; 55 charset utf-8,gbk; 56 }
生成密码文件
htpasswd -c /home/nginx/passwd.db admin