Sweshi's Tutorials

Installing and configuring Apache Web Server (HTTPD) in Centos 9 Linux and below

Allowing HTTPD through the Linux Firewall

We will first create our own default webpage in the document root so that we test whether this can be seen from other computers. To create our own default page, go to the “/var/www/html” directory. This is the document root of the server which is used to place the website files. Inside the directory, add an “index.php” file which will be our new page for the server. If you have multiple websites, you can create folders within the “/var/www/html”.

navigating to the document root of the apache web server

Make sure that you add the following code to the “index.php” file. This is of course a simple web page, you can create your own default web page for your server.

Replacing the default start page for the apache web server

If the index.php file was created well, run “lynx http://localhost” and see that the default page is able to open as shown in the figure.

Testing the new Apache Test page
Allowing HTTP through the Linux Firewall

I will first show how to do this in Centos 7,8 and 9

Allowing http through the firewall in centos 7,8 and 9 permanetly

On centos 7,8 and 9, the HTTP service can be allowed through the firewall by running the command “firewall-cmd –add-service=http –permanent”. The firewall can then be reloaded for the command to take effect using the command “firewall-cmd –reload”.

Allowing http through the firwall on Centos 6 and below

To allow the http service through the firewall on centos 6 and below, use the iptables command to allow port 80’s source and destination ports on both the input and output chains.

testing the httpd connection to the server from a windows machine

I tried opening the web page on my windows machine by opening my Microsoft edge browser and the typing “http://192.168.43.162” which is using the IP address of the virtual machine. As you can see, the web page was able to open well.