0% found this document useful (0 votes)
10 views

Module 3 - Server services

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Module 3 - Server services

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Server service:

In this module, we will cover five key lessons focused on installing and configuring real-world Linux server
services. By the end of this module, you will have hands-on experience setting up and managing critical
infrastructure components that are essential for any robust Linux-based system.
The first lesson will dive into web servers, covering the installation and configuration of both Apache and
Nginx. You'll learn how to set up virtual hosts, configure SSL/TLS, and optimize performance for your web
applications.

Next, we'll explore database servers, walking through the installation and configuration of MySQL and
PostgreSQL. You'll gain practical experience creating databases, managing user accounts, and
implementing backup and recovery strategies.

In the third lesson, we'll introduce virtualization using the Kernel-based Virtual Machine (KVM)
hypervisor. You'll learn how to install and configure KVM, create and manage virtual machines, and set up
virtual networks to suit your needs.

The fourth lesson will focus on Zabbix, a powerful open-source monitoring solution. You'll install and
configure the Zabbix server, deploy agents on your systems, and learn how to set up comprehensive
monitoring and alerting for your infrastructure.

Finally, we'll cover FTP servers and Samba file sharing. You'll learn how to install and configure an FTP
server, set up user access controls, and implement Samba to provide file sharing capabilities across your
network.

Throughout this module, you'll have the opportunity to apply your knowledge by working on real-world
projects, ensuring that you gain practical experience that can be directly applied in your professional or
personal Linux server administration endeavors.
Lesson 1 - Web servers (Apache, Nginex) installation and configuration

Lesson 2 - Database Servers (Mysql, PostgreSQL) installation and configuration

Lesson 3 - Virtualization (KVM) installation and configuration

Lesson 4 – Zabbix Monitoring Installation and configuration

Lesson 5 - FTP server and Samba file sharing

--------------------------------------------------------------------------------------------------------------------------------------

Lesson 1 - Web servers (Apache, Nginex) installation and configuration

Apache and Nginx are two of the most popular web servers used on the internet today. Here's a brief
explanation of each:

Apache:
Apache is an open-source web server software that was first released in 1995. It is the most widely used
web server software, powering over 46% of all websites on the internet as of 2023. Apache is highly
customizable, with a vast ecosystem of modules and plugins that allow users to extend its functionality. It
is known for its stability, security, and performance, particularly for serving static content. Apache
supports a wide range of operating systems, including Linux, Windows, and macOS.

Nginx:
Nginx (pronounced "engine-x") is another popular web server software, known for its high performance
and efficiency, particularly in handling high-traffic websites. Nginx was initially developed in 2002 to
address the shortcomings of Apache in handling large numbers of concurrent connections. Unlike
Apache, which uses a threaded or process-based architecture, Nginx employs an event-driven,
asynchronous architecture that allows it to handle more concurrent connections with lower resource
usage. Nginx is often used as a reverse proxy, load balancer, and HTTP cache, in addition to its web server
capabilities.

Both Apache and Nginx have their own strengths and are suitable for different use cases. Apache is
generally better suited for serving dynamic content and running complex web applications, while Nginx
excels at serving static content and handling high-traffic loads. Many web servers use a combination of
Apache and Nginx, with Nginx handling the front-end and Apache handling the back-end.

Step 1: Install Apache

Update your system packages:


$ sudo dnf update -y

Install the Apache package:

$ sudo dnf install httpd -y

Step 2: Manage Apache Service

Start the Apache service:

$ sudo systemctl start httpd

Enable Apache to start on boot:

$ sudo systemctl enable httpd

Check the status of the Apache service:

$ sudo systemctl status httpd

Step 3: Configure Firewall

Open the firewall port for HTTP (port 80):

$ sudo firewall-cmd --add-service=http --permanent

$ sudo firewall-cmd --reload

Step 4: Access Apache Default Web Page


Open your web browser and go to your server's IP address or domain name (e.g., http://your_server_ip).
You should see the Apache default test page.

Step 5: Host a Simple Website

Create a directory for your website:

$ sudo mkdir -p /var/www/example.com/html

Set up a simple HTML file:

$ echo "Welcome to example.com" | sudo tee /var/www/example.com/html/index.html

Create a virtual host configuration file:

$ sudo nano /etc/httpd/conf.d/example.com.conf

Add the following content:

<VirtualHost *:80>

ServerName example.com

ServerAlias www.example.com

DocumentRoot /var/www/example.com/html

ErrorLog /var/log/httpd/example.com_error.log

CustomLog /var/log/httpd/example.com_access.log combined

</VirtualHost>

Restart Apache to apply the changes:

# sudo systemctl restart httpd


Lesson 2 - Database Servers (Mysql, PostgreSQL) installation and configuration

Step 1: Update Your System

Update your system packages:

$ sudo dnf update -y

Step 2: Install PostgreSQL

Install PostgreSQL server and contrib packages:

$ sudo dnf install postgresql-server postgresql-contrib -y

Step 3: Initialize the PostgreSQL Database

Initialize the database:

$ sudo postgresql-setup --initdb

Step 4: Start and Enable PostgreSQL Service

Start the PostgreSQL service:

$ sudo systemctl start postgresql

Enable PostgreSQL to start on boot:

$ sudo systemctl enable postgresql

Step 5: Configure PostgreSQL

Set a password for the PostgreSQL user:

$ sudo passwd postgres

Switch to the PostgreSQL user:


$ su - postgres

Access the PostgreSQL prompt:

psql

Step 6: Create a Database and User

Create a new user:

CREATE USER your_user WITH PASSWORD 'your_password';

Create a new database:

CREATE DATABASE your_database;

Grant privileges to the user:

GRANT ALL PRIVILEGES ON DATABASE your_database TO your_user;

Step 7: Test PostgreSQL Installation

Connect to the new database:

$ psql -U your_user -d your_database

Create a simple table:

CREATE TABLE example (

id SERIAL PRIMARY KEY,

name VARCHAR(100),

age INT

);
Insert a test record:

INSERT INTO example (name, age) VALUES ('John Doe', 30);

Query the table:

SELECT * FROM example;

Lesson 2: Database Servers (Mysql, PostgreSQL) installation and configuration

Database servers are the backbone of modern web applications, providing a reliable and scalable storage
solution for data. Two of the most popular open-source database servers are MySQL and PostgreSQL.
Here's a brief overview of their installation and configuration:

MySQL:
MySQL is a relational database management system (RDBMS) that is widely used in web applications. To
install MySQL, you can download the appropriate package for your operating system from the official
MySQL website. The installation process varies depending on the platform, but it generally involves
running the installer and following the on-screen instructions. After installation, you can configure MySQL
by setting up user accounts, creating databases, and tuning the server's settings to optimize performance.

One of the key steps in configuring MySQL is setting up the root user password. This is the main
administrative account that has full access to the database. You can also create additional user accounts
with specific permissions, depending on the needs of your application. MySQL also provides various
configuration options, such as setting the maximum number of connections, adjusting the memory
allocation for the query cache, and enabling or disabling specific features.

PostgreSQL:
PostgreSQL, often referred to as Postgres, is another popular open-source RDBMS that is known for its
reliability, data integrity, and advanced features. The installation process for PostgreSQL is similar to
MySQL, with the user downloading the appropriate package for their operating system from the official
PostgreSQL website.
After the initial installation, you'll need to configure PostgreSQL to suit your needs. This includes creating
user accounts, setting up databases, and tuning the server's settings. Unlike MySQL, PostgreSQL has a
more robust security model, with the ability to define granular permissions for different user roles. You
can also configure PostgreSQL to use various authentication methods, such as password-based or
certificate-based authentication.

One of the key advantages of PostgreSQL is its support for advanced data types, such as arrays, JSON, and
geospatial data. This makes it a popular choice for applications that require more complex data storage
requirements. Additionally, PostgreSQL has a rich ecosystem of extensions and plugins that can be easily
integrated to add new functionality to the database server.

Step 1: Update Your System

Update your system packages:

$ sudo dnf update -y

Step 2: Install PostgreSQL

Install PostgreSQL server and contrib packages:

$ sudo dnf install postgresql-server postgresql-contrib -y

Step 3: Initialize the PostgreSQL Database

Initialize the database:

$ sudo postgresql-setup --initdb

Step 4: Start and Enable PostgreSQL Service


Start the PostgreSQL service:

$ sudo systemctl start postgresql

Enable PostgreSQL to start on boot:

$ sudo systemctl enable postgresql

Step 5: Configure PostgreSQL

Set a password for the PostgreSQL user:

$sudo passwd postgres

Switch to the PostgreSQL user:

$ su - postgres

Access the PostgreSQL prompt:

$ psql

Step 6: Create a Database and User

Create a new user:

➢ CREATE USER your_user WITH PASSWORD 'your_password';


Create a new database:

➢ CREATE DATABASE your_database;

Grant privileges to the user:

➢ GRANT ALL PRIVILEGES ON DATABASE your_database TO your_user;

Step 7: Test PostgreSQL Installation

Connect to the new database:

$ psql -U your_user -d your_database

Create a simple table:

CREATE TABLE example (


id SERIAL PRIMARY KEY,
name VARCHAR(100),
age INT
);

Insert a test record:

➢ INSERT INTO example (name, age) VALUES ('John Doe', 30);


Query the table:

➢ SELECT * FROM example;


Lesson 3 - Virtualization (KVM) installation and configuration

Virtualization is a powerful technology that allows you to run multiple operating systems on a single
physical server. One of the most popular virtualization solutions for Linux is Kernel-based Virtual Machine
(KVM).

Installing KVM on Linux:

To install KVM on a Linux system, you'll first need to ensure that your system meets the hardware
requirements, such as support for hardware virtualization (Intel VT-x or AMD-V). Then, you can install the
necessary packages using your Linux distribution's package manager.

For example, on Ubuntu, you can install KVM with the following command:

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

Configuring KVM:

After installing KVM, you'll need to configure it to suit your needs. This involves setting up virtual
networks, creating and managing virtual machines (VMs), and configuring storage for the VMs.

One of the key steps in configuring KVM is setting up the virtual network. This typically involves creating a
bridge interface that the VMs can use to connect to the physical network. You can also configure firewall
rules and other network settings to control the traffic to and from the VMs.
To create and manage VMs, you can use a command-line tool like virsh or a graphical user interface (GUI)
tool like GNOME Boxes or virt-manager. These tools allow you to create new VMs, start and stop them,
and configure their hardware and software settings.

Finally, you'll need to configure storage for the VMs, which can be done using a variety of storage options,
such as local storage, network-attached storage (NAS), or storage area networks (SANs).

Maintaining KVM:

Maintaining a KVM-based virtualization environment requires ongoing monitoring and management. This
includes keeping the host system and guest VMs up-to-date with security patches, monitoring resource
utilization, and troubleshooting any issues that may arise.

Additionally, you may need to perform regular backups of the VMs to ensure that you can restore them in
the event of a failure or disaster. KVM provides various tools and utilities to automate these tasks and
ensure the reliability and availability of your virtualized environment.

By following these steps, you can successfully install, configure, and maintain a KVM-based virtualization
environment on your Linux system to meet your organization's computing needs.

https://docs.oracle.com/en/virtualization/oracle-linux-virtualization-manager/getstart/getstarted-
manager-install.html#manager-config

Lesson 4 – Zabbix Monitoring Installation and configuration

Zabbix is a powerful open-source monitoring solution that allows you to monitor the health and
performance of your IT infrastructure, including servers, network devices, and applications. Here's a high-
level overview of installing and configuring Zabbix on a Linux system:

Installing Zabbix:
The first step in setting up Zabbix is to install the necessary packages on your Linux system. Zabbix
provides official repositories for various Linux distributions, making the installation process relatively
straightforward.

For example, on a CentOS/RHEL system, you can install Zabbix by adding the official Zabbix repository and
then running the following commands:

sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

Configuring the Zabbix Server:


After installing the necessary packages, you'll need to configure the Zabbix server to connect to a
database (typically MySQL or PostgreSQL) and set up the web interface.

This involves tasks such as:

Creating a database and user for Zabbix

Updating the Zabbix server configuration file (zabbix_server.conf) with the database connection details

Configuring the web interface by setting the appropriate database connection settings and timezone

Additionally, you may need to configure firewall rules to allow communication between the Zabbix server
and agents, as well as any other components of your monitoring setup.

Deploying Zabbix Agents:


Zabbix agents are small software components installed on the hosts you want to monitor. These agents
collect performance and status data from the host and send it back to the Zabbix server.

To deploy Zabbix agents, you can download the appropriate package for your Linux distribution and install
it on the target hosts. Once installed, you'll need to configure the agent to connect to the Zabbix server
and specify any additional monitoring settings.

Ongoing Maintenance and Customization:


After the initial setup, you'll need to regularly maintain and customize your Zabbix monitoring solution to
meet the changing needs of your IT infrastructure. This may include tasks such as:

➢ Configuring additional monitoring templates and items


➢ Creating custom dashboards and reports
➢ Setting up alerting and notification rules
➢ Performing regular backups and upgrades
➢ Troubleshooting any issues that may arise

By following these steps, you can successfully install, configure, and maintain a Zabbix monitoring solution
on your Linux system, providing you with valuable insights into the health and performance of your IT
infrastructure.

https://www.zabbix.com/download?zabbix=6.0&os_distribution=oracle_linux&os_version=9&component
s=server_frontend_agent&db=mysql&ws=apache

Lesson 5- FTP server and Samba file sharing

You might also like