DEV Community

Revathi Joshi for AWS Community Builders

Posted on • Updated on • Originally published at aws.plainenglish.io

Install Apache Web Server on CentOS8

Image description

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


2. Install an Apache HTTP Web Server

Again use sudo for elevated permissions and y for no user interaction during installation.

Image description

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


3. Enable the Apache Web Server

Enabling Apache will allow it to start on boot.

Image description

Image description

The system is now up and usable.

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

Image description

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

Image description

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

Image description

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

Image description

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

Image description


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

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


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

Image description

and save it.

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

(http://54.177.1.119)

Image description

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

Top comments (0)