How to install Apache web server on CentOS 8 or Stream

- Advertisment -
- Advertisement -

CentOS 8 Linux is here along with rolling -based OS Stream, let’s see how we can turn them into a web server by installing opensource Apache webserver software. 

Apache web-server is a free and open-source and power a huge majority of Linux web hosting services. It can be installed on almost any Linux whether it is CentOS 8, 7 or 6; RHEL, Ubuntu, Debian etc. It is created by the Apache foundation and supports both HTTPS and HTTP protocols. On CentOS or RHEL system or their forks, it’s recognized as httpd service.

Steps to install Apache on CentOS 8 Linux

The steps here are performed on the CentOS 8, however, they are applicable and the same for Redhat 8 and CentOS stream Linux.

Open Command Terminal and login as root

To install Apache (httpd) on CentOS 8 we need root access without that this server system will not let us install anything. Moreover, if you are using the Graphical user interface, then you can access the Command terminal from the Activities menu given on the top right side taskbar.

Update system

Run the following command to update any installed packages to their latest and stable version.

dnf update


yum update

Note: The latest CentOS is based on RHEL 8 and now supports dnf command, however, yum still can be used as usual. However, here we are showing both.

Command to Install Apache (httpd) on CentOS 8 or Stream

So, here is the single-line command to download and install Apache web server packages. Which is given below with both yum and dnf.

yum install httpd


dnf install httpd

The output of the above command:

  Package                   Arch          Version                                       Repository        Size
 httpd     x86_64    2.4.37-11.module_el8.0.0+172+85fc1f40      AppStream             1.7 M
Installing dependencies:
 apr             x86_64        1.6.3-9.el8                                   AppStream        125 k
 apr-util     x86_64        1.6.1-6.el8                                   AppStream        105 k
 centos-logos-httpd        noarch        80.5-2.el8                                    AppStream         24 k
 httpd-filesystem          noarch        2.4.37-11.module_el8.0.0+172+85fc1f40        AppStream          34 k
 httpd-tools               x86_64        2.4.37-11.module_el8.0.0+172+85fc1f40         AppStream        102 k
 mod_http2                 x86_64        1.11.3-2.module_el8.0.0+10+abf51267           AppStream        156 k
 mailcap                   noarch        2.1.48-3.el8                                  BaseOS            39 k
Installing weak dependencies:
 apr-util-bdb              x86_64        1.6.1-6.el8                                   AppStream         25 k
 apr-util-openssl          x86_64        1.6.1-6.el8                                   AppStream         27 k

Transaction Summary
Install  10 Packages

Total download size: 2.3 M
Installed size: 6.1 M
Is this ok [y/N]: 

When it asks for your permission to install Apache, enter Y and let it download and install this open-source web server.

Apache installation command
httpd installation successful

Enable Apache webserver

After the successful installation, we will enable the Apache webserver service so that it can be automatically started even after booting the system The command for that is.

systemctl enable httpd

Start httpd service n CentOS 8

Now we will start the service of Apache so that we can access and install our website on it.

systemctl start httpd

The output of the above commands:

[root@localhost ~]# systemctl enable httpd
 Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/httpd.service.
 [root@localhost ~]# systemctl start  httpd
 [root@localhost ~]#

Open HTTP firewall port 80

If you are accessing the webserver on the same local machine where you have installed it then there will be no problem. However, the moment you want to access it using some other computer remotely or even using one which is on the same network of the webserver, the CentOS 8 firewall will not let you do that. Thus, we have to open the Port number 80 in the firewall so that users can connect to our Apache webserver.
To do this use the below command.

Command to expose the http port 80 to the public.

firewall-cmd --zone=public --permanent --add-service=http

Now, reload the firewall service to make the changes into effect.

firewall-cmd --reload

In the same, way you can also open https 443 port for your Apache web server on CentOS 8.

Access webserver to test

Now, finally, its time to see whether our installed httpd server is working or not. For that simply open your browser and type web server installed CentOS 8 IP address. For example, Our system Ip is, thus the URL will be like this

If you are on the same local system then you can also use localhost as well: http://localhost:80 or http://127.0.01:80.

The result will be like this:

Demo Apache index.html page

Install your web page or site on the webserver

To access the web directory where you can put your web files on the server follow the below command.

cd /var/www/html/

Add your files to HTML directory and after that, you can access them locally or remotely on your web server.

Other Related Articles:

H2S Media Team
H2S is a group of tech enthusiasts those are passionate about latest technology developments. They always like to solve own technical problems and share the same solution with others through this Website.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts

How to open Windows PowerShell in a specific location of explorer

We hardly like dealing with the Command-line interface or CLI on Windows, but it becomes inevitable at...

All about the EROFS file system for Linux file system by Huawei

When it comes to storage technologies, the reliability of storing data digitally is improving day by day,...

How to convert Word document to JPEG online on all platforms

After you have finished preparing some documents using Microsoft Word, the program of choice for most users,...

IT Industry experts weigh in on International Data Privacy Day

Data Privacy Day aims to raise awareness and promote privacy and data protection best practices and is observed in...
- Advertisement -

Stellar Announces New Version of Bitraser on Data Privacy Day

BitRaser Data Erasure software helps companies safely reuse old IT assets & mitigate risk of data breach. On the occasion...

Portronics introduces POWER BUN, a Universal USB Charging Hub

As per the recent press release public by the Portronics, the company has launched a new product that is...

- Advertisment -
- Advertisement -

You might also likeRELATED
Recommended to you