安装 Nginx

--安装依赖
yum install -y wget gcc gcc-c++ make pcre pcre-deve zilib zlib-devel openssl-devel libxml2 libxml2-dev libxslt-devel git 

--下载Nginx 扩展dav模块
git clone https://github.com/arut/nginx-dav-ext-module.git

--下载 Nginx并且解压
wget http://nginx.org/download/nginx-1.18.0.tar.gz、
tar zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0

--编译Nginx 并安装
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_dav_module --add-module=../nginx-dav-ext-module
make && make install

编辑配置文件

--创建webdav 目录
mkdir /webdav
touch /webdav/hello
vim /usr/local/nginx/conf/nginx.conf
http {
...........省略
server {
  listen       80;
  client_max_body_size 10m;
location / {
  root /webdav;
  dav_methods PUT DELETE MKCOL COPY MOVE;
  dav_ext_methods PROPFIND OPTIONS;
  create_full_put_path  on;
  dav_access user:rw group:r all:r;
  #min_delete_depth 0;
  auth_basic "webdav";
  auth_basic_user_file /usr/local/nginx/passwd;
   }
  }

配置参数解释

client_max_body_size 10m;   上传文件的最大容量限制
dav_methods PUT DELETE MKCOL COPY MOVE;  允许指定的'HTTP'方法和'WebDAV'方法,支持以下方法PUT、DELETE、MKCOL、COPY、MOVE
create_full_put_path  on;   'WebDAV'规范仅允许在已存在的目录中创建文件。开启该指令允许创建所有需要的中间目
dav_access user:rw group:r all:r;  指定访问权限
min_delete_depth 0;   允许DELETE方法移除文件,前提是请求路径中的元素数量不小于指定的数量

配置访问密码

--安装htpasswd工具
yum install -y httpd-tools

--使用htpasswd 生成用户认证文件
htpasswd -c /usr/local/nginx/passwd admin

启动 Nginx

/usr/local/nginx/sbin/nginx

验证

--下载raidrive 或WinScp  工具
raidrive官网 https://www.raidrive.com/
WinScp官网   https://winscp.net/

1

2

最后修改:2022 年 02 月 17 日
如果觉得我的文章对你有用,请随意赞赏