OpenResty 搭建文件服务器

2019-08-05  本文已影响0人  Bug2Coder

一、安装

1、二进制源码下载

  1.1、下载地址:
  https://openresty.org/cn/download.html

2、以Ubuntu为例下载,编译,安装和配置
  2.1、环境库安装
       sudo apt install libpcre3-dev libssl-dev perl make build-essential curl
  2.2、下载源码
       1.15.8.1:https://openresty.org/download/openresty-1.15.8.1.tar.gz
       解压
        tar -xzvf openresty-1.15.8.1.tar.gz
  2.3、编译
      进入 openresty-VERSION/ 目录, 然后输入以下命令配置:
      ./configure
      默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录
      您可以指定各种选项,比如

      ./configure --prefix=/opt/openresty \
            --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_postgres_module
      
      make编译-多核编译
      make -j2
  2.4、安装
      sudo make install
  2.5、配置
      配置文件目录:/usr/local/openresty/nginx/conf/nginx.conf
      在http -> server 字段下添加

      location /files { # 访问地址
      autoindex on; # 开启索引功能
      autoindex_exact_size off; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)  
      autoindex_localtime on; # 显示本机时间而非 GMT 时间  
      alias /var/files;   # 显示的根索引目录
}
  注意:alias files目录为下载根目录,自行创建
  文件准备
  文件放到/var/files中去即可 
  执行 chmod 777 /var/files -R 更改文件权限

  运行
  sudo /usr/local/openresty/bin/openresty 
  sudo /usr/local/openresty/bin/openresty -s reload 
  每次修改配置文件之后都需要执行reload

  访问
  使用浏览器访问 
  http://ip/files 
  即可看到/var/files中的文件,并可以下载
上一篇 下一篇

猜你喜欢

热点阅读