CentOS 7 下 Nginx 下载服务器搭建

CentOS 7 下 Nginx 下载服务器搭建

文章目录

  • CentOS 7 下 Nginx 下载服务器搭建
      • 安装 Nginx
      • 配置 Nginx
      • 创建对应目录
      • 启动 Nginx 服务
      • 查看下载文件
      • 下载文件
      • 参考

安装 Nginx

[root@192 ~]# rpm -ivh nginx-1.16.1-1.el7.ngx.x86_64.rpm

配置 Nginx

[root@192 ~]# cat /etc/nginx/conf.d/download.conf 
server {
    listen       8001;          # a customed port

    # download
    autoindex on;               # enable directory listing output
    autoindex_exact_size off;   # output file sizes rounded to kilobytes, megabytes, and gigabytes
    autoindex_localtime on;     # output local times in the directory

    location / {
        root /usr/share/nginx/nginx_download;
    }
}

创建对应目录

[root@192 ~]# mkdir /usr/share/nginx/nginx_download
[root@192 ~]# chown -R nginx.nginx /usr/share/nginx/nginx_download

启动 Nginx 服务

[root@192 ~]# /usr/sbin/nginx -c /etc/nginx/nginx.conf

查看下载文件

[root@192 ~]# curl 192.168.157.151:8001
<html>
<head><title>Index of /</title></head>
<body>
<h1>Index of /</h1><hr><pre><a href="../">../</a>
<a href="openssl-OpenSSL_1_1_1p.tar.gz">openssl-OpenSSL_1_1_1p.tar.gz</a>                      01-Jul-2022 00:00     10M
</pre><hr></body>
</html>

下载文件

[root@lsr update]# wget http://192.168.157.151:8001/openssl-OpenSSL_1_1_1p.tar.gz
--2022-07-01 00:01:26--  http://192.168.157.151:8001/openssl-OpenSSL_1_1_1p.tar.gz
Connecting to 192.168.157.151:8001... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10039630 (9.6M) [application/octet-stream]
Saving to: ‘openssl-OpenSSL_1_1_1p.tar.gz’

100%[===========================================================>] 10,039,630  --.-K/s   in 0.06s   

2022-07-01 00:01:26 (173 MB/s) - ‘openssl-OpenSSL_1_1_1p.tar.gz’ saved [10039630/10039630]

参考

  • NGINX as a file server

你可能感兴趣的:(服务器配置,服务器,nginx,centos)