RedHat Certified Engineer Notes
RedHat Certified Engineer Notes
➢ Apache Server
➢ NFS Server
➢ FTP Server
➢ MariaDB Server
What is Apache Web Server?
Apache HTTP Server is a free and open-source web server that delivers web
content through the internet. It is commonly referred to as Apache and after
development, it quickly became the most popular HTTP client on the web. It’s
widely thought that Apache gets its name from its development history and
process of improvement through applied patches and modules but that was
corrected back in chkconfig httpd on 2000. It was revealed that the name
originated from the respect of the Native American tribe for its resiliency and
durability.
Now, before we get too in depth on Apache, we should first go over what a web
application is and the standard architecture usually found in web apps.
Working of Apache
Apache is not any physical server; it is software that executes on the server.
However, we define it as a web server. Its objective is to build a connection
among the website visitor browsers (Safari, Google Chrome, Firefox, etc.) and
the server. Apache can be defined as cross-platform software, so it can work on
Windows servers and UNIX.
---------------------------------------------------------------------------------------------------------------
Its a System V-launched service. The NFS server package includes three
facilities, included in the portmap and nfs-utils packages.
• portmap : It maps calls made from other machines to the correct RPC
service (not required with NFSv4).
• nfs: It translates remote file sharing requests into requests on the local
file system.
• rpc.mountd: This service is responsible for mounting and
unmounting of file systems
• /etc/exports : Its a main configuration file of NFS, all exported files and
directories are defined in this file at the NFS Server end.
• /etc/fstab : To mount a NFS directory on your system across the
reboots, we need to make an entry in /etc/fstab.
• /etc/sysconfig/nfs : Configuration file of NFS to control on which port
rpc and other services are listening.
We need to install NFS packages on our NFS Server as well as on NFS Client
machine.
After installing packages and starting services on both the machines, we need to
configure both the machines for file sharing.
/myfiles 192.188.100.900(rw,sync,no_root_squash)
NFS Options
Some other options we can use in “/etc/exports” file for file sharing is as
follows.
• ro: With the help of this option we can provide read only access to the
shared files i.e client will only be able to read.
• rw: This option allows the client server to both read and write access
within the shared directory.
• sync: Sync confirms requests to the shared directory only once the
changes have been committed.
• no_subtree_check: This option prevents the subtree checking. When a
shared directory is the subdirectory of a larger file system, nfs performs
scans of every directory above it, in order to verify its permissions and
details. Disabling the subtree check may increase the reliability of NFS,
but reduce security.
• no_root_squash: This phrase allows root to connect to the designated
directory.
For more options with “/etc/exports“, you are recommended to read the man
pages for export.
Setting Up the NFS Client
After configuring the NFS server, we need to mount that shared directory or
partition in the client server.
/myfiles 192.188.100.901
The above mount command mounted the nfs shared directory on to nfs client
temporarily, to mount an NFS directory permanently on your system across the
reboots, we need to make an entry in “/etc/fstab“.
o FTP is a standard internet protocol provided by TCP/IP used for transmitting the files
from one host to another.
o It is mainly used for transferring the web page files from their creator to the computer
that acts as a server for other computers on the internet.
o It is also used for downloading the files to computer from other servers.
Objectives of FTP
o It provides the sharing of files. o It is used to encourage the use
of remote computers.
Why FTP?
Backward Skip 10sPlay VideoForward Skip 10s
Although transferring files from one system to another is very simple and
straightforward, but sometimes it can cause problems. For example, two systems may
have different file conventions. Two systems may have different ways to represent text
and data. Two systems may have different directory structures. FTP protocol overcomes
these problems by establishing two connections between hosts. One connection is
used for data transfer, and another connection is used for the control connection.
Mechanism of FTP
The above figure shows the basic model of the FTP. The FTP client has three
components: the user interface, control process, and data transfer process. The server
has two components: the server control process and the server data transfer process.
o Control Connection: The control connection uses very simple rules for
communication. Through control connection, we can transfer a line of command or line
of response at a time. The control connection is made between the control processes.
The control connection remains connected during the entire interactive FTP session.
o Data Connection: The Data Connection uses very complex rules as data types may
vary. The data connection is made between data transfer processes. The data
connection opens when a command comes for transferring the files and closes when
the file is transferred.
FTP Clients
o FTP client is a program that implements a file transfer protocol which allows you to
transfer files between two hosts on the internet.
o It allows a user to connect to a remote host and upload or download the files.
o It has a set of commands that we can use to connect to a host, transfer the files between
you and your host and close the connection.
o The FTP program is also available as a built-in component in a Web browser. This GUI
based FTP client makes the file transfer very easy and also does not require to
remember the FTP commands.
Advantages of FTP:
o Speed: One of the biggest advantages of FTP is speed. The FTP is one of the fastest
way to transfer the files from one computer to another computer. o Efficient: It is more
efficient as we do not need to complete all the operations to get the entire file. o
Security: To access the FTP server, we need to login with the username and password.
Therefore, we can say that FTP is more secure.
o Back & forth movement: FTP allows us to transfer the files back and forth. Suppose
you are a manager of the company, you send some information to all the employees,
and they all send information back on the same server.
Stepwise Implementation
At first SSH into your Linux virtual machine with a user who has sudo permissions
and follows the following steps:
• Can jail users into its home directory with a feature called chroot.
We will set this up later in this article.
• Can limit bandwidth.
• Supports virtual users
• Supports virtual IP configuration
• Supports IPv6
Type in the following command to install vsftpd sudo apt
install vsftpd
Now we will check if the vsftpd service is active or not. Type in sudo
systemctl status vsftpd
You can see under the Active heading that it’s active and running. systemctl
command is used to manage and check services on Linux. We can also use this
command to enable and disable services on
Linux. If your vsftpd is not active, then type in sudo
systemctl enable --now vsftpd
The –now flag ensures that enable command affects our service immediately and not
after a reboot.
Enter your password, leave other values empty, and at last, enter Y to save changes.
Now, for security purposes, we will disable ssh permission for this user.
Type in sudo nano
/etc/ssh/sshd_config
Press Ctrl + x then y then enter. Now, restart the SSH service so that these new settings
take effect. sudo systemctl restart sshd
Now, we will change this directory’s owner to our admin user. Type in sudo chown
adminuser /ftp
If you want to upload files to any folder that is not owned by your admin user, you
will have to change that folder’s owner using the abovementioned command.
Step 5: Configure and secure vsftpd
Open the vsftpd configuration file. Type in sudo
nano /etc/vsftpd.conf
local_enable=YES
write_enable=YES
...
Also, we opened ports 5000 to 10000 in step 2 for passive mode, so now we will let
vsftpd know which ports to use for passive FTP connection. Add the following lines in
vsftpd.conf file
pasv_min_port=5000
pasv_max_port=10000
Now, we will specify the default directory for FTP connections which will open when
someone connects to our FTP server. Add the following line local_root=/ftp
Remember, do not put any space before and after = in this configuration file.
Locking user into the home directory
Now, for security reasons, we will lock the ftpuser to the default directory, as by
default, a user can browse the whole Linux server. To do this, vsftpd uses chroot. To
do this, un-comment the following lines
...
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
...
Also, add the following line as it is not in the configuration file by default
allow_writeable_chroot=YES
The first line enables chroot feature for local users which includes our admin user
and our ftpuser. The second and third lines let us choose which users to apply to
chroot to.
Setting file permission
local_umask=0002
This line will set the modification permission of every new file created to 664(-rw-rw-
r-) and of every new folder to 775(rwxrwxr-x). With this, the ftpuser can only read
and download files from every sub-directory of our FTP directory, but it does not
have permission to upload anything to our FTP directory since it is not the owner.
Press Ctrl + x then y then enter. Now, we need to create that list file. Type in
sudo touch /etc/vsftpd.chroot_list sudo
nano /etc/vsftpd.chroot_list
Whatever users you specify in this file, will not be chroot-ed. So add your admin
username in this file because we do not want to lock it. Press Ctrl + x then y then
enter. Now we need to restart our vsftpd server so that all these settings get applied
immediately. Type in sudo systemctl restart --now vsftpd
MairaDB
MariaDB, a fork of MySQL is one of the most popular open-source SQL
(Structured Query Language) relational databases management systems,
made by the original developers of MySQL. It is designed for speed, reliability,
and ease of use.
It’s development started due to concerns that arose when MySQL was
acquired by Oracle Corporation in 2009. Now, the developers and
maintainers of MariaDB do monthly merges with the MySQL code base to
ensure that MariaDB has any relevant bug fixes added to MySQL.
MariaDB server is available under the GPL license, version 2, and its client
libraries for C, Java, and ODBC are distributed under the LGPL license,
version 2.1 or higher. It is offered in two different editions.
The first is the MariaDB Community Server which you can download, use,
and modify for free. The second edition is the MariaDB Enterprise Server
intended to replace proprietary databases and adopt open source in the
enterprise.
Just like MySQL, MariaDB also uses a client/server model with a server
program that files requests from client programs. As is typical of client/server
computer systems, the server and the client programs can be on different
hosts.
MySQL Client-
Server Structure
If you are migrating to MariaDB, its data files are generally binary compatible
with those from the equivalent MySQL version, and also MariaDB’s client
protocol is binary compatible with MySQL’s client protocol.
For both MariaDB and MySQL, all client APIs and structs are identical, all
ports and sockets are generally the same, and all MySQL connectors for
programming languages such as Python, Perl, PHP, Ruby, Java, and MySQL
C connector, etc work unchanged under MariaDB.
Also, MariaDB comes with several client programs such as the popular
command-line utilities: mysql, mysqladmin, and mysqldump, for administering
databases.
sudo mysql_secure_installation
4. Finally test your installation by running:
mysql -u root -p