How to Install and Configure Apache Web Server in Centos 7,8 / Redhat 7,8 / Fedora

Share on :

How to Install and Configure Httpd Apache Web Server for Static WebHosting in Centos 7,8 / Redhat 7,8 / Fedora

Apache web Server is one of the most popular web server software. Apache Web Server works on Server – Client Architecture. It works on port number 80 and uses tcp protocol. Many Web Hosting providers use Apache web server to host our websites .In this blog we will learn that how can we setup Static Web Hosting Server in Centos / Redhat / Fedora.

Package Name – httpd
Document Root – /var/www/html
Main Configuration File – /etc/httpd/conf/httpd.conf

1) Install the Apache Server Package.

——< for Centos 7,8 / Rhel 7,8 >——
yum install httpd -y
——-< Fedora >——
dnf install httpd -y

2) Upload you website content to /var/www/html.

/var/www/html is called the Document Root of Apache Web server. In this Directory we have to put or upload our website files (i.e) index.html , style.css files, etc.

Note:- you need to place Main Website Index file which you want to display on web browser name as index.html. because by default apache web server reads the index.html file

I am creating a file in /var/www/html called index.html for the demonstration.

vi /var/www/html/index.html
press i to get into insert mode

<html>
<head>
<title>Lets Learn Tech</title>
</head>
<body>
<h1>My Website</h1>
</body>
</html>

after making changes in the file press escape from keyboard and press :wq! to write and quite from file.

3) Start and Enable the httpd Service.

systemctl start httpd
systemctl enable httpd

4) Apply the firewall rule.

firewall-cmd –permanent –add-service=http
firewall-cmd –reload

5) Open your Web Browser.

http://<your_ip>

Our Web Server is up and Running.

If you want to open it with a domain. like www.example.com then you need a DNS Server or you can just setup /etc/hosts file for local name resolution. but this you need to setup on all the client systems in which you want to open the website by your domain. or you must setup a DNS Server.

vi /etc/hosts
press i to get into insert mode
your_server_ip your_domain_name

192.168.122.1     www.letslearntech.com
after making changes in the file press escape from keyboard and press :wq! to write and quite from file.

If you are using a public ip then you need to buy a domain and point it to your public ip.


Share on :

You may also like...

6 Responses

  1. Tanishq says:

    very nicely explained

  2. I don’t even know how I ended up here, but I thought this
    post was great. I do not know who you are but certainly you’re going to a famous
    blogger if you are not already 😉 Cheers!

  3. buy domain says:

    Thanks for another informative website.

    The place else may just I get that kind of information written in such a perfect means?
    I’ve a challenge that I am just now running on, and I’ve been at the glance
    out for such info.

Leave a Reply

Your email address will not be published. Required fields are marked *