Linux下利用vsftpd + nginx 搭建文件服务器

1.安装与查看是否已经安装vsftpd

yum -y install vsftpd // 安装
rpm -qa | grep vsftpd // 查看是否已经安装

2.配置vsftpd文件

安装成功后,有/etc/vsftpd/vsftpd.conf文件,是vsftpd的配置文件

例如配置,登录成功后能访问的文件

3.添加用户

useradd ftpadmin // 添加用户
passwd ftpadmin // 为用户设置密码,输入两次

4.vsftpd常用操作命令

service vsftpd start // 启动Vsftpd服务
service vsftpd stop // 停止Vsftpd服务的命令
service vsftpd restart // 重新启动Vsftpd服务
service vsftpd status // 检查Vsftpd服务状态
chkconfig vsftpd on // 设置开机启动vsftpd服务

5.安装nginx

先安装依赖

yum install gcc-c++ // 安装gcc
yum install -y pcre pcre-devel // PCRE pcre-devel 安装
yum install -y zlib zlib-devel // zlib 安装
yum install -y openssl openssl-devel // OpenSSL 安装

然后去nginx官网下载.gz包

下载地址:https://nginx.org/en/download.html

tar -zxvf nginx-1.12.1.tar.gz // 解压nginx
cd nginx-1.12.1
make
make install // 编译安装

6.配置nginx (根据自己的需求配置)

一般默认安装路径在 /usr/local/nginx/conf/nginx.conf

server {
        listen 80; # 监听端口
        server_name  localhost; # 请求地址
        index  index.html index.htm index.php;
        location /images {
                root /home/ftpfile/;   # vsftpd文件路径
                autoindex on;
        }
}

7.nginx常用命令

whereis nginx // 查找nginx安装路径
cd /usr/local/nginx/sbin/
./nginx   (启动)
./nginx -s stop (停止)
./nginx -s quit  (关闭)
./nginx -s reload (重启)

8.配置成功访问结果

发布了21 篇原创文章 · 获赞 0 · 访问量 599

猜你喜欢

转载自blog.csdn.net/Stodger0216/article/details/104333491