Install Apache Web Server on CentOS8
Tags: apache, centos, aws, devops
Published: 2022-10-02 13:19:11


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwldj7sjj0o321o19tr4.png)




This tutorial will show you how to set up an Apache Web server in a matter of minutes.

Apache is the most widely used web server software. Developed and maintained by Apache Software Foundation, Apache is an open source software available for free. As a Web server, Apache is responsible for accepting directory (HTTP) requests from Internet users and sending them their desired information in the form of files and Web pages.

---



**Here are the items you will need:**

- **_CentOS8 Server_** - Some online training programs, such as A Cloud Guru, offer a “playground” for you to set up a server for free.

- **_Command Line Interface (CLI)_** - where are going to use a few commands to set up Apache on our server as well as a few additional steps to make it ready to be viewed on the internet.

- _**An AWS account with sudo privileges**_ - It is best practice to not use the Root account to make changes to your server.

---


**Here is what you have to do:**

1. Update all the packages on the server.
2. Install an Apache HTTP Web Server.
3. Enable the Apache Web Server.
4. Opening Port 80 on the firewall.
5. Grab the Public IP Address of the server and paste it on any 
   web browser to see the Apache Test Page.
6. Customize your Web Browser to see your own message.

---


## 1. Update all the packages on the server

Update all the packages to the latest version to ensure that the server is up to date. Installation requires _sudo_ for elevated permissions and _y_ for no user interaction, on the command line.

Enter the command: `sudo yum -y update`



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fl2fo847bflvwsubdokw.png)


---


## 2. Install an Apache HTTP Web Server

Again use _sudo_ for elevated permissions and _y_ for no user interaction during installation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kl86os8wejhhwment837.png)


This step may also take a few minutes as it pulls all files needed to install Apache on your CentOS8 server. Once completed, you will be greeted with a “Complete!” message.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twgo5dxsyu3c1zfjcp7u.png)

---

## 3. Enable the Apache Web Server

Enabling Apache will allow it to start on boot.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohls3v538sa4ackh0vpc.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by8r812nsj7ufe673or9.png)


The system is now up and usable.

To verify the status of Apache on your server, use the following command:



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9d4v6mut3dnynq3yydio.png)



You want to ensure that the active status says “active (running)” in this message.

---


## 4. Opening Port 80 on the firewall


we need to open port 80 to accept HTTP connection.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y6heyvefwhlbpb2vu4v.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipro5kl8rm6xrwv8ju5e.png)


now add the services — HTTP/HTTPS permanently to the configuration


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/myx58ni7s1qm5k52dwmw.png)


To check whether or not HTTP/HTTPS services are added permanently


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0khuqbd8ywox60zcjun.png)


After adding the services, you will need to reload the firewall so that the changes can take effect.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hh3b4flypmf458919blm.png)


---

## 5. Grab the Public IP Address of the server and paste it on any web browser to see the Apache Test Page

First we need to obtain our public IP address of the server


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwxvsuqyfgvsvhfxiojt.png)


The above command gave you the Public IP Address as “54.177.1.119”. Paste this in any web browser. Use **http://your server IP** 
**(http://54.177.1.119)**



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0547rdma67ulfu241xf.png)

---

**Extra Point**

## 6. Customize to see your own message on your Web browser instead of seeing the standard Apache Web page.

As _sudo, cd to /var/www/html/_. Create an _index.html_ file with your customized message



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yy2t15avh07vb9s0y53h.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu35a3b16rwn5x8nw5lj.png)


and save it.

Now paste the same command in any web browser. Use **http://yourserver IP**

**(http://54.177.1.119)**



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s8v25crhmv9iu03fzr2.png)


_Congratulations! You can see your own customized message on the Web Browser._