I usually use the scp command to upload files to the server, which is simple and secure. However, the upgrade mechanism of Wordpress requires using the ftp access method, so I have to configure an ftp server on my VPS. There are two options for configuring an ftp server on Linux: vsftp and wu-ftp, each with its own advantages. Personally, I recommend vsftp, except for the Chinese garbled code issue.
VSFTP is an FTP server software based on the GPL license, used on Unix-like systems. As the name suggests, the developer's intention was code security.
Wu-Ftpd stands for Washington University FTP and can be selected in most Linux distributions. WU-FTPD is a high-performance server software and is widely used as an FTP server due to its powerful features and high throughput.
- Install vsftpd
apt-get install vsftpd
- Modify /etc/vsftpd.conf to configure the FTP server. If you need a certain configuration, remove the "#" symbol in front of the corresponding line in the conf file.
listen=YES # Server listening
#anonymous_enable=YES # Optional, enable anonymous access to the server if YES
local_enable=YES # Allow local host access
write_enable=YES # Allow writing
anon_upload_enable=YES # Optional, allow anonymous users to upload#
anon_mkdir_write_enable=YES # Optional, allow anonymous users to create folders#
dirmessage_enable=YES # Enable directory messages
xferlog_enable=YES # Enable FTP logging
#xferlog_file=/var/log/vsftp.log # Optional, if you need to adjust the location of the FTP log
connect_from_port_20=YES # Optional, allow using port 20 as the data transfer port
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
The following content needs to be manually added#
charset_filter_enable=YES # Enable character set filtering to solve garbled code issues
charset_client=UTF8 # Client character set
charset_server=UTF8 # Server character set
-
Adjust the user for the service. After vsftpd is installed, the ftp user group will be added. Add the ftp user you need to use to this group. If you need to allow file uploads, open the write permissions for the corresponding directory.
-
Open the system firewall and allow external access
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables-save