利用 Nginx 搭建小型的文件服务器

1.查看 Nginx 配置

android@localhost:/etc/nginx/conf.d$ nginx -h
nginx version: nginx/1.14.0 (Ubuntu)
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
​
Options:
-?,-h         : this help
-v           : show version and exit
-V           : show version and configure options then exit
-t           : test configuration and exit
-T           : test configuration, dump it and exit
-q           : suppress non-error messages during configuration testing
-s signal     : send signal to a master process: stop, quit, reopen, reload
-p prefix     : set prefix path (default: /usr/share/nginx/)
-c filename   : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
​

由上可知 Nginx 的配置文件位于:"/etc/nginx/nginx.conf",里面可以修改处理器数量、日志路径、pid文件路径等。在 nginx.conf 末尾有一句:"include /etc/nginx/conf.d/*.conf" —— 推荐把用户自己的配置放到 "conf.d/"

2.修改 "conf.d/default.conf" 内容

root@localhost:/# vim /etc/nginx/conf.d/default.conf
​
​
autoindex on;           # 显示目录
autoindex_exact_size on;# 显示文件大小
autoindex_localtime on; # 显示文件时间
charset utf-8,gbk;     # 专治中文乱码
​
server {
  listen       8080 default_server;
  listen       [::]:8080 default_server;
  server_name _;
  root         /var/files;
​
​
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
​
    location / {
    }
​
    error_page 404 /404.html;
        location = /40x.html {
    }
​
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

3.修改权限(此步骤根据需要设置)

在访问 “/sdcard” 目录时出现了 "403 Forbidden" 错误

修改 "/etc/nginx/nginx.conf" 文件,将第一句 "user www-data;" 更改为 "user root;"

root@localhost:/# vim /etc/nginx/nginx.conf
​
​
# user www-data;
user root;
worker_processes auto;
​
…省略…

4.重载 Nginx

/etc/init.d/nginx reload

5.大功告成

5-1.浏览器访问 http://[nginx-ip]:8080,可以看到 "/var/files" 目录下的文件,点击可下载。

5-2.若需访问其他目录,可通过命令 "ln -s" 在 “files” 目录下创建软连接。

采用绝对路径建立软链接:
ln -s /sdcard/LuAnda/DownloadsAria2 /var/files/DownloadsAria2

利用 Nginx 搭建小型的文件服务器的更多相关文章

  1. 利用nginx搭建小型的文件服务器

    PS内的文件如果需要共享给其他计算机下载,可以选择ftp的方式,优点是操作性很高,修改删除下载等等都可以,但是速度略慢. 如果仅仅是将VPS作为文件中转站,可以尝试用Nginx架设一个简单的文件服务器 ...

  2. 利用Nginx搭建http和rtmp协议的流媒体服务器[转]

    利用nginx搭建http和rtmp协议的流媒体服务器 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtmp协议:同时打开rtmp的hls功能资料:HTTPLive Streaming( ...

  3. 利用nginx搭建tomcat集群

    1.tomcat集群 利用nginx对请求进行分流,将请求平均的分给不同的tomcat去处理,减少单个tomcat的负载量,提高tomcat的响应速度. 2.创建多个tomcat服务器(同一个服务器上 ...

  4. 利用nginx搭建文件服务器

    1.安装nginx 安装教程:https://www.cnblogs.com/sunny1009/p/11411673.html 2.配置nginx 配置server节点下的location部分和se ...

  5. Nginx之使用nginx搭建简单的文件服务器

    使用nginx可以搭建简单文件服务器 安装nginx(不详述) 修改配置文件 /usr/local/nginx/conf/nginx.conf user root; /usr/local/nginx/ ...

  6. 利用nginx搭建RTMP视频点播、直播、HLS服务器(转)

    开发环境 Ubuntu 14.04 server nginx-1.8.1 nginx-rtmp-module nginx的服务器的搭建 安装nginx的依赖库 sudo apt-get update ...

  7. 利用nginx搭建RTMP视频点播、直播、HLS服务器

    开发环境 Ubuntu 14.04 server nginx-1.8.1 nginx-rtmp-module nginx的服务器的搭建 安装nginx的依赖库 sudo apt-get update ...

  8. 利用nginx搭建https服务器

    一.HTTPS简介 HTTPS其实是有两部分组成:HTTP + SSL / TLS,也就是在HTTP上又加了一层处理加密信息的模块.服务端和客户端的信息传输都会通过TLS进行加密,所以传输的数据都是加 ...

  9. 利用Nginx搭建RTMP视频直播,点播服务器,ffmpeg推流,回看

        一.环境和工具 ubuntu 14.04 desktop 不用server的原因是一部分的演示用到了linux视频播放和直播软件,自己还要装桌面,麻烦. 不建议使用 最新的16TLS,我一开始 ...

随机推荐

  1. centos7上用docker搭建简单的前后端分离项目

    1. 安装docker Docker 要求 CentOS 系统的内核版本高于 3.10 ,首先验证你的CentOS 版本是否支持 Docker . 通过 uname -r 命令查看你当前的内核版本 使 ...

  2. SQL 练习20

    查询各科成绩前三名的记录 select a.sid,a.cid,a.score from sc a left join sc b on a.cid = b.cid and a.score<b.s ...

  3. rsync基本使用

    概念 rsync是linux系统下的数据镜像备份工具.使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH.rsync主机同步. 目前,已支持跨平台,可以在Windo ...

  4. mysql悲观锁和乐观锁

    悲观锁 查出来的数据必须是根据索引查出来的,不然锁表. # 语法 select * from table where id = 1 for update; 乐观锁 使用一个标识 cas 比较后替换 如 ...

  5. WPF 中的 Command 命令

    <Window x:Class="CommandDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx ...

  6. swagger2 注解说明文档

    @Api:用于类上,说明该类的作用.可以标记一个Controller类做为swagger 文档资源 @Api(value = "xxx", description = " ...

  7. Thread类的常用方法----多线程基础练习

    创建多线程程序的第一种方式----继承Thread类 常用API 构造方法 public Thread() :分配一个新的线程对象. public Thread(String name) :分配一个指 ...

  8. BeanUtils实现对象拷贝(三)

    package beanutil; import java.lang.reflect.InvocationTargetException; import java.util.Date; import ...

  9. 使用Operator State方式

    使用 operator state的方式有以下几种: 方式一: stateful function(RichFunction) 实现 CheckpointFunction 接口 必须实现两个方法:Vo ...

  10. 【SpringMVC】RESTFul简介以及案例实现

    RESTful 概念 REST:Representational State Transfer,表现层资源状态转移. 资源 资源是一种看待服务器的方式,即,将服务器看作是由很多离散的资源组成.每个资源 ...