We have already covered several episodes where we are setting up our Linux server to work with a netcore application. But in order to deploy the application, we need to upload files to our server, so we will create an FTP server.
To carry out these steps, you should be connected to your server via ssh
and use a user with sudo access.
Table of Contents
1 - Enable the EPEL Repository
First of all, you can update your system using (not mandatory)
sudo yum -y update
Keep in mind that this command will update all the packages you have installed.
The reason we will enable the EPEL repository is so that we can install a large number of open-source packages from the yum package manager.
In our case, we are looking for the ProFTPD package. It is very simple, secure, and easy to configure.
To enable the EPEL repository, run the following commands:
$ sudo wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm$ sudo rpm -ivh epel-release-7-11.noarch.rpm
And to check if the repository is available, you can run the following command:
$ sudo yum repolist | grep epel
2 - Install FTP Server on CentOS
Once we have the repository, we simply have to use one command to install our FTP server
$ sudo yum install proftpd proftpd-utils
3 - Start ProFTPD
Once we have installed the service, all that remains is to start it. For that, we run two quick commands:
$ sudo systemctl start proftpd$ sudo systemctl enable proftpd
4 - Check ProFTPD Installation on CentOS
Technically, we can already connect to our VPS server using any FTP client, such as FileZilla.
As an example for the host, I have used the IP 192.168.1.1
, but you should put your own server's IP, the same one you use to connect via ssh
.
Now you'll have the ability to upload and download files to and from your server without any issues.
If you cannot connect, it is probably a port issue. Go to step 7 to see how to open them.
5 - ProFTPD Configuration Changes
If you make any changes to the configuration (you can see different configurations here that are implemented in the /etc/proftpd.conf
file), please note that for these to take effect we need to restart the service. To do so, we run the following command:
$ sudo systemctl restart proftpd
6 - Check Log Files
If you have any issue, ProFTPD will log errors in the /var/log/proftpd
directory.
Of course, you can make a "quick check" of the current status of the service by executing:
$ sudo systemctl status proftpd
Common Errors
When we install our Linux server, by default it has a lot of security, so port 21, which is used to connect to the FTP server, will be closed.
First, you should check if it is closed or not.
If you run the following command
$ sudo iptables -nvL
You can check if the port is open or not. The information shown can look a bit confusing, but as an example, it looks something like this:
So, we need to open the port we are going to use (21 and 22)
7 - Open FTP Port in Linux
To open a port in Linux, simply run the following command
$ sudo firewall-cmd --permanent --add-port=21/tcp$ sudo firewall-cmd --permanent --add-service=ftp
And if you also want the FTP port, you should also open port 22
$ sudo firewall-cmd --permanent --add-port=22/tcp$ sudo firewall-cmd --permanent --add-service=ftp
Conclusion
You definitely need an FTP server to upload your files to your server, and ProFTPD is a great option due to all its configuration options.
If there is any problem you can add a comment bellow or contact me in the website's contact form