b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

apache 配置这篇文章介绍怎样用web服务器列出指定的目

电脑杂谈  发布时间:2018-02-19 07:47:44  来源:网络整理

apache安装与配置_apache 配置_apache 配置 静态

这篇文章介绍怎样用web服务器列出指定的目录和文件,并对指定目录进行授权访问。apache 配置apache 配置

使用Nginx列出目录

准备工作 - 安装nginx和创建一些目录和文件:

复制代码 代码如下:

$ sudo apt-get install nginx

$ cd /usr/share/nginx

$ mkdir web

$ sudo mkdir directory{1,2,3}

$ sudo touch file{1,2,3}

$ ls

directory1 directory2 directory3 file1 file2 file3

Nginx配置:

复制代码 代码如下:

$ sudo vim /etc/nginx/conf.d/list.conf

server {

listen 80;

server_name 192.168.1.201;

root /usr/share/nginx/web;

index index.html;

apache安装与配置_apache 配置_apache 配置 静态

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

$ sudo service nginx restart/reload

当访问,屏幕显示:

Nginx列出目录和文件并用密码控制访问权限配置方法

现在就可以用web服务器来共享文件;但前提是根目录下必须没有index.html文件。

授权访问指定的目录

有些目录不想让所有人看到,只有指定的用户输入密码后才能访问,例如directory只能由test1访问:

step1安装htpasswd

复制代码 代码如下:

$ sudo apt-get install apache2-utils

step2创建密码文件

复制代码 代码如下:

$ sudo htpasswd -c /home/test/.htpasswd test1

New password:

Re-type new password:

Adding password for user test1

apache 配置 静态_apache 配置_apache安装与配置

step3修改Nginx配置文件

复制代码 代码如下:

$ sudo vim /etc/nginx/conf.d/list.conf

server {

listen 80;

server_name 192.168.1.201;

root /usr/share/nginx/web;

index index.html;

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

location ^~/directory1/ {

auth_basic "input you user name and password";

auth_basic_user_file /home/test/.htpasswd;

}

}

重启Nginx服务后,访问directory1目录时会提示输入登入信息:

Nginx列出目录和文件并用密码控制访问权限配置方法

您可能感兴趣的文章:


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-84739-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...