最近开始用wordpress搭建本身的我的博客,在自动更新wordpress的时候要用到FTP服务,在Ubuntu的云主机上配置FTP花费了很多时间,在这里做一下总结。html
搭建FTP确定是要用大名鼎鼎的vsftpd。具体步骤以下:shell
安装vsftpdbash
apt-get install vsftpd
配置vsftpd参数
配置文件是/etc/vsftpd.conf,首先先备份原配置文件。wordpress
cp /etc/vsftpd.conf /etc/vsftpd.conf.old
而后修改其中的参数,以下:this
# Example config file /etc/vsftpd.conf listen=YES<br>anonymous_enable=NO #禁止匿名登陆 local_enable=YES #本地用户能够登陆 write_enable=YES #容许写操做,包括上传,修改等 # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES #显示目录信息 use_localtime=YES #使用本地时间 xferlog_enable=YES #开启日志 xferlog_file=/var/log/vsftpd.log #日志存储位置 xferlog_std_format=YES #日志标准格式 chroot_local_user=YES #将用户限制在他们的home目录 chroot_list_enable=YES #启用能够chroot的用户的列表 chroot_list_file=/etc/vsftpd.chroot_list #指定能够chroot的用户列表的位置 ls_recurse_enable=YES #容许递归操做 secure_chroot_dir=/var/run/vsftpd/empty #必须为空
关于chroot_local_user,chroot_list_enable,chroot_list_flie三个参数,有以下解释。插件
# You may restrict local users to their home directories. See the FAQ for # the possible risks in this before using chroot_local_user or # chroot_list_enable below. # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot)
也就是说,若是chroot_local_user
选项为NO
,则本地帐户能够访问除home目录之外的其余目录,此时chroot_list_file
是不能够chroot()
的用户;当chroot_local_user
为YES
时,本地帐户只能访问自家目录,此时chroot_list_file
变成能够chroot()
的用户列表。翻译
完成上面这些以后,编辑/etc/shells
文件,若是没有/sbin/nologin
,要添加这一行。rest
/sbin/nologin
添加用户日志
useradd -g ftp -d /home/username -m username #-g选项指明用户所在的组 #-d选项指明用户的家目录 #-m指明用户名 passwd username #给用户设置密码
若是只执行完上述步骤,在wordpress中使用ftp更新时仍然会遇到没法建立目录的错误,缘由是新建的用户并无wordpress所在目录的修改权限,因此要修改用户的权限。(我这里wordpress所在的目录是/var/www/html/wordpress
)code
chmod -R 755 /var/www/html/wordpress chown -R username:ftp /www/html/wordpress
重启vsftpd服务
service vsftpd restart
而后就可使用ftp进行wordpress的更新了,也能够安装新的翻译,主题,插件。