Cyberithub

Step by Step Guide to Install Apache 2.4.6 web server on RHEL 7/CentOS 7

Advertisements

In this article, I will take you through the Step by Step Guide to Install Apache 2.4.6 web server on RHEL 7/CentOS 7. Apache is a well Known open source cross platform web Server used by many tech giants across the globe like IBM, Adobe, Paypal, LinkedIn, Facebook. Being open source, it is very popular among Server Programmers and developers who can built and configure their own modules based on the requirements. More on Apache Official Documentation. Here we will look into the detailed steps required to Install Apache web server on RHEL 7/CentOS 7.

What is Web Server 

A web server is a Server Side software which listens and processes the client http or https requests. A Request always originates from the client machine to web server where application or other documents are hosted to be served. Connection to the web server are usually established through three way handshake mode where client send SYN requests first which gets acknowledged by the Server through ACK response and so on.

Step by Step Guide to Install Apache 2.4.6 web server on RHEL 7/CentOS 7 2

Install Apache web server on RHEL 7/CentOS 7

Also Read: How to Install MariaDB 5.5 Server on RHEL 7/CentOS 7 Linux with Easy Steps

Step 1: Prerequisites

a) You need to have a running RHEL 7/CentOS 7 System.

b) You should have yum tool installed in your Server. You can check Top 22 YUM command examples in RedHat/CentOS 7 to know more about yum command.

c) You need to have root or sudo access to run privileged commands. Please Check How to Add User to Sudoers to know more about providing sudo access to the User.

Step 2: Update Your Server

Before going through the steps to Install Apache Server on RHEL 7/CentOS 7, it is always recommended to update your server using yum update -y command as shown below.

[root@localhost ~]# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package bind-export-libs.x86_64 32:9.11.4-16.P2.el7 will be updated
---> Package bind-export-libs.x86_64 32:9.11.4-16.P2.el7_8.6 will be an update
---> Package binutils.x86_64 0:2.27-43.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-43.base.el7_8.1 will be an update
---> Package ca-certificates.noarch 0:2019.2.32-76.el7_7 will be updated
---> Package ca-certificates.noarch 0:2020.2.41-70.0.el7_8 will be an update
---> Package curl.x86_64 0:7.29.0-57.el7 install apache will be updated
---> Package curl.x86_64 0:7.29.0-57.el7_8.1 install apache will be an update
---> Package dbus.x86_64 1:1.10.24-13.el7_6 will be updated
---> Package dbus.x86_64 1:1.10.24-14.el7_8 will be an update
---> Package dbus-libs.x86_64 1:1.10.24-13.el7_6 will be updated
---> Package dbus-libs.x86_64 1:1.10.24-14.el7_8 will be an update
---> Package device-mapper.x86_64 7:1.02.164-7.el7 will be updated
---> Package device-mapper.x86_64 7:1.02.164-7.el7_8.2 will be an update
---> Package device-mapper-event.x86_64 7:1.02.164-7.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.164-7.el7_8.2 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.164-7.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.164-7.el7_8.2 will be an update
---> Package device-mapper-libs.x86_64 7:1.02.164-7.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.164-7.el7_8.2 will be an update
---> Package firewalld.noarch 0:0.6.3-8.el7 will be updated
---> Package firewalld.noarch 0:0.6.3-8.el7_8.1 will be an update
---> Package firewalld-filesystem.noarch 0:0.6.3-8.el7 will be updated
---> Package firewalld-filesystem.noarch 0:0.6.3-8.el7_8.1 will be an update
---> Package grub2.x86_64 1:2.02-0.81.el7.install apache will be updated
---> Package grub2.x86_64 1:2.02-0.86.el7.install apache will be an update
---> Package grub2-common.noarch 1:2.02-0.81.el7.centos will be updated
---> Package grub2-common.noarch 1:2.02-0.86.el7.centos will be an update
---> Package grub2-pc.x86_64 1:2.02-0.81.el7.install apache will be updated
---> Package grub2-pc.x86_64 1:2.02-0.86.el7.centos will be an update
---> Package grub2-pc-modules.noarch 1:2.02-0.81.el7.centos will be updated
---> Package grub2-pc-modules.noarch 1:2.02-0.86.el7.centos will be an update

Step 3: Install Apache web server on RHEL 7/CentOS 7

After successfully updating the Server you need to install apache package using yum install httpd -y command as shown below. This command will download and install the latest available httpd package from Enabled Repository along with its dependencies.

[root@localhost ~]# yum install httpd -y
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 206 kB 00:00:00
(3/4): updates/7/x86_64/primary_db | 4.5 MB 00:00:01
(4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-93.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-93.el7.centos for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-5.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-93.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
httpd x86_64 2.4.6-93.el7.centos base 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-5.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-93.el7.centos base 92 k
mailcap noarch 2.1.41-2.el7 base 31 k

Transaction Summary
========================================================================================================================================================================
Install 1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/apr-util-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY] 0.0 B/s | 0 B --:--:-- ETA install apache 2.4.6 web server install apache 2.4.6
Public key for apr-util-1.5.2-6.el7.x86_64.rpm is not installed
(1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00
(2/5): httpd-tools-2.4.6-93.el7.centos.x86_64.rpm | 92 kB 00:00:00
(3/5): apr-1.4.8-5.el7.x86_64.rpm | 103 kB 00:00:00
(4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(5/5): httpd-2.4.6-93.el7.centos.x86_64.rpm | 2.7 MB 00:00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.5 MB/s | 3.0 MB 00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-8.2003.0.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-5.el7.x86_64 1/5
Installing : apr-util-1.5.2-6.el7.x86_64 2/5
Installing : httpd-tools-2.4.6-93.el7.centos.x86_64 3/5
Installing : mailcap-2.1.41-2.el7.noarch 4/5
Installing : httpd-2.4.6-93.el7.centos.x86_64 5/5
Verifying : apr-1.4.8-5.el7.x86_64 1/5
Verifying : httpd-tools-2.4.6-93.el7.centos.x86_64 2/5
Verifying : mailcap-2.1.41-2.el7.noarch 3/5
Verifying : httpd-2.4.6-93.el7.centos.x86_64 4/5
Verifying : apr-util-1.5.2-6.el7.x86_64 5/5

Installed:
httpd.x86_64 0:2.4.6-93.el7.centos

Dependency Installed:
apr.x86_64 0:1.4.8-5.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-93.el7.centos mailcap.noarch 0:2.1.41-2.el7

Complete!

Step 4: Install Other httpd Packages

You can also install other important httpd package like httpd-devel package using yum install httpd-devel -y command as shown below. This command will install httpd-devel package which provides other important tools required by Apache web server.

[root@localhost ~]# yum install httpd-devel -y

Step 5: Verify Apache Server Installation

Once packages are installed, you can check the installation by using rpm -qa | grep -i httpd command as shown below. This command will query the httpd package availability from RPM database maintained in the Server which has information of all the installed packages.

[root@localhost ~]# rpm -qa | grep -i httpd
httpd-2.4.6-93.el7.centos.x86_64
httpd-tools-2.4.6-93.el7.centos.x86_64

Step 6: Check Apache(httpd) version

If you want to check the Apache version then you need to use httpd -v command as shown below. As you can see from below output, current installed version is 2.4.6.

[root@localhost ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Apr 2 2020 13:13:23

Step 7: Start Apache Web Server

By default Apache will use the configuration from httpd.conf file which will be available under /etc/httpd/conf path. You can start the httpd service by using systemctl start httpd command and then check the status by using systemctl status httpd command as shown below. If you want you can enable the service under SystemD by using systemctl enable httpd command.

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2020-10-17 04:59:00 EDT; 2s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2031 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─2031 /usr/sbin/httpd -DFOREGROUND
├─2032 /usr/sbin/httpd -DFOREGROUND
├─2033 /usr/sbin/httpd -DFOREGROUND
├─2034 /usr/sbin/httpd -DFOREGROUND
├─2035 /usr/sbin/httpd -DFOREGROUND
└─2036 /usr/sbin/httpd -DFOREGROUND

Oct 17 04:59:00 localhost systemd[1]: Starting The Apache HTTP Server...
Oct 17 04:59:00 localhost httpd[2031]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerNam...is message
Oct 17 04:59:00 localhost systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

Step 8: Remove httpd Package from RHEL 7/CentOS 7

If you want to remove apache httpd package from RHEL 7/CentOS 7 Server then you need to use yum remove httpd -y command as shown below.

[root@localhost ~]# yum remove httpd -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-93.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Removing:
httpd x86_64 2.4.6-93.el7.centos @base 9.4 M

Transaction Summary
========================================================================================================================================================================
Remove 1 Package

Installed size: 9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : httpd-2.4.6-93.el7.centos.x86_64 1/1
Verifying : httpd-2.4.6-93.el7.centos.x86_64 1/1

Removed:
httpd.x86_64 0:2.4.6-93.el7.centos

Complete!

 

 

 

 

 

Popular Recommendations:-

Best Steps to Install Java on RHEL 8/CentOS 8

5 Examples to Turn Off SELinux Temporarily or Permanently on RHEL 8/CentOS 8

Useful C Program to List Network Interfaces using only 30 Lines of Code

Best Explanation of Wrapper Classes in Java: Autoboxing and Unboxing with Examples

5 Best Ways to Become root user or Superuser in Linux (RHEL/CentOS/Ubuntu)

How to Install PHP on RedHat/CentOS 7 with Easy Steps

7 Easy Steps to Install PHP on RHEL 8/CentOS 8

Easy Steps to Install Java on Ubuntu 20.04

Leave a Comment