揭开nginx神秘面纱[二.nginx的使用:通过浏览器访问本地电脑的目录文件]

xiaoxiao2021-02-28  97

这是我使用nginx做的第一个需求:通过浏览器访问本地mac某一个目录下的内容(支持中文噢):

在 nginx/servers 下添加配置文件:localhost.conf(可随便定义),内容如下:

### 浏览器浏览本地目录http://localhost/ server {         listen   80;# 确定80端口没有被占用哦,也可以自定义其他端口号         server_name  localhost;        # access_log  /var/log/nginx/access.log;        # location / {        #         index  index.php index.html index.htm;        # }        # location /Users/lifangyu {        #        autoindex on;        # }        location / {           root /Users/lifangyu;            # //指定实际目录绝对路径;                      charset utf-8,gbk;           autoindex on;                        # //开启目录浏览功能;           autoindex_exact_size off;            # //关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;           autoindex_localtime on;              # //开启以服务器本地时区显示文件修改日期!        } } #### ==========================

重启nginx,在浏览器http://localhost/ 看到如下

转载请注明原文地址: https://www.6miu.com/read-42509.html

最新回复(0)