欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

使用Nginx搭建文件服务器 nginxwebdav 

程序员文章站 2024-03-14 18:02:34
...
下载Nginx软件包
wget http://nginx.org/download/nginx-1.17.3.tar.gz

解压Nginx软件包
tar -zxvf nginx-1.17.3.tar.gz

切换到Nginx目录
cd nginx-1.17.3

安装Nginx依赖包
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel gcc gcc-c++

安装Nginx到系统
./configure --with-http_dav_module
make
make install

修改Nginx的配置
cd /usr/local/nginx/conf
vi nginx.conf
============================================================
location / {
    root   html;
    client_body_temp_path html;
    dav_methods PUT;
    create_full_put_path on;
    dav_access user:rw group:r all:r;

    limit_except GET {
        auth_basic "closed site";
        auth_basic_user_file htpasswd;
    }
    index  index.html index.htm;
}
============================================================

写入密码到文件
echo 'bessky:52PrWRJdkBic6' > htpasswd

启动Nginx服务
../sbin/nginx

优化配置
vi /etc/security/limits.conf
============================================================
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
============================================================
ulimit -n

开机启动
cd /lib/systemd/system
vi nginx.service
============================================================
[Unit]
Description=nginx service
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target
============================================================
开机启动
systemctl enable nginx
禁止启动
systemctl disable nginx
启动服务
systemctl start nginx.service
停止服务
systemctl stop nginx.service
重启服务
systemctl restart nginx.service
相关标签: nginx webdav