Centos7下安装FTP文件服务器

2019/03/28 09:12
阅读数 33

1. 安装VSFTP
[root@localhost ~]# yum -y install vsftpd

2修改配置 vim /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES

listen=NO


listen_ipv6=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
local_root=/mnt/disk/nginx/html/temp
anon_root=/mnt/disk/nginx/html/temp
allow_writeable_chroot=YES
userlist_file=/etc/vsftpd/user_list
userlist_enable=NO
chroot_local_user=YES
pam_service_name=vsftpd
tcp_wrappers=YES

3.以下文件中注释掉root 用户
user_list ftpuer
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
touchlms
touch

4.授权目录
chmod -R 777 /mnt/disk/nginx/html/temp

此时查看日志文件tail -f /var/log/secure

CentOS vsftp 553 Could not create file 错误解决(

输入 setsebool allow_ftpd_full_access on )
症状:用户可以从远程服务器登录ftp,可以查看ftp各种路径文件,但是不能上传,上传提示553 Could not create file.
查看了各种文件夹权限,都设置没问题,最后发现是SELinux问题,

查看SELinux设置:

[root@beaconvm02 vsftpd]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off

问题在于,要把allow_ftpd_full_access设置为on,修改设置
[root@beaconvm02 vsftpd]# setsebool allow_ftpd_full_access on(重新开机后失效) 或 setsebool -P allow_ftpd_full_access on(长久生效)

再查看一遍
[root@beaconvm02 vsftpd]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> on
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off
[root@beaconvm02 vsftpd]#
再重新上传文件,成功。

5.开启,重启,停止服务
systemctl start vsftpd.service
systemctl restart vsftpd.service
systemctl stop vsftpd.service
systemctl status vsftpd.service

systemctl enable vsftpd.service  开机自启动

7.默认开启vsftp服务
chkconfig vsftpd on

8.centos 卸载vsftpd方法
如果服务器上安装了vsftpd,配置出错需要卸载vsftpd
[root@localhost ~]# rpm -aq vsftpd
vsftpd-2.0.5-16.el5_5.1 #此处是查找vsftpd的返回结果
[root@localhost ~]# rpm -e vsftpd-2.0.5-16.el5_5.1

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
在线直播报名
返回顶部
顶部