温馨提示×

Linux FTP服务如何启动

小樊
41
2026-08-01 06:24:34
栏目: 智能运维

在 Linux 上启动 FTP 服务,常见的是使用 vsftpd(最常用)或 ProFTPD。下面以 vsftpd 为例说明,适用于大多数发行版(CentOS、RHEL、Rocky、Ubuntu、Debian 等)。


一、安装 vsftpd

Ubuntu / Debian

sudo apt update
sudo apt install vsftpd

CentOS / RHEL / Rocky / AlmaLinux

sudo yum install vsftpd        # CentOS 7
sudo dnf install vsftpd        # CentOS 8+

二、启动 FTP 服务

启动 vsftpd

sudo systemctl start vsftpd

设置开机自启

sudo systemctl enable vsftpd

查看运行状态

sudo systemctl status vsftpd

看到 active (running) 表示已成功启动。


三、防火墙放行 FTP 端口

FTP 默认使用 21 端口。

firewalld(CentOS 7+)

sudo firewall-cmd --permanent --add-service=ftp
sudo firewall-cmd --reload

UFW(Ubuntu)

sudo ufw allow 21/tcp
sudo ufw reload

四、基本配置(可选但推荐)

配置文件路径:

/etc/vsftpd.conf

常见配置项:

anonymous_enable=NO        # 禁止匿名登录
local_enable=YES           # 允许本地用户登录
write_enable=YES           # 允许写操作
chroot_local_user=YES      # 限制用户在家目录

修改后重启服务:

sudo systemctl restart vsftpd

五、测试 FTP 服务

本地测试

ftp localhost

远程测试

ftp 服务器IP

六、常见问题

1. 连接被拒绝

  • vsftpd 未启动
  • 防火墙未放行
  • 端口不是 21

2. SELinux 影响(CentOS/RHEL)

getenforce

如果是 Enforcing,可临时关闭测试:

sudo setenforce 0

七、其他 FTP 服务(简要)

ProFTPD

sudo apt install proftpd
sudo systemctl start proftpd

如果你能告诉我:

  • Linux 发行版
  • 本地服务器 还是 云服务器
  • 是否需要 匿名访问 / 虚拟用户

我可以给你一份更精确的配置方案

0