Nginx文件服务器搭建

一、Nginx安装

1.yum安装

cat >/etc/yum.repos.d/nginx.repo<<EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/x86_64
gpgcheck=0
enabled=1
EOF

2.官网rpm直接安装

wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.12.1-1.el7.ngx.x86_64.rpm
rpm -ivh nginx-1.12.1-1.el7.ngx.x86_64.rpm

二、新增配置Nginx

/etc/nginx/conf.d/fileserver.conf

server {
    listen              53229;
    server_name         127.0.0.1;
    access_log    /var/log/nginx/files.log;
    include "/etc/nginx/conf.d/fileserver-location.tmp";
}

/etc/nginx/conf.d/fileserver-location

location / {
    root              /usr/share/nginx/;
    autoindex on;
    #auth_request /auth;
    allow             all;
    deny              all;
    # A special location that doesn't require authentication for agents upgrade
}

三、重启Nginx

systemctl restart nginx
原文地址:https://www.cnblogs.com/Ghostant/p/14749698.html