How to Install Apache on RHEL 7 (Red Hat Enterprise Linux) Operating System

January 2, 2020

Comments

Adsense

Adsense

Adsense

Adsense

When we are thinking about web server the first name is coming Apache HTTP server, it is most popular in the world for hosting any type of web applications or websites. The most important thing about Apache web server is, it is free and open-source web server and providing a powerful feature for your web application, including support of cross-platform.
 
In this tutorial, we will explain the process of installing the Apache HTTP webserver on RHEL 7 (Red Hat Enterprise Linux) Operating System.

Prerequisites

To install Apache HTTP web server on your RHEL 7 Linux system, you should have user access to login on system and need sudo privileges to execute administrative commands to install applications.

Install Apache

The apache HTTP web server packages are inbuilt in Red Hat repository packages which we can easily install using “yum” command. The only thing is to know the Apache HTTP server’s service is known as “httpd” in RHEL Operating System.

To install HTTP package, first, need to update Red Hat package index and install httpd using the following command:

$ sudo yum update
$ sudo yum install httpd

Now, the apache httpd web server is installed. You can enable and start httpd service using following command:

$ sudo systemctl enable httpd
$ sudo systemctl start httpd

Configure the Firewall for Apache httpd server on RHEL 7

Nowadays, every system we protecting with Firewall to secure system and services. If Firewall also protests your RHEL system, you need to open HTTP (80) and HTTPS (443) port to access the webserver.

You can open the Apache ports using the following command:
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
$ sudo firewall-cmd --reload

Verify Apache Installation

To verify apache httpd web server installed  and everything working as per the instructions, you can check the status of httpd service status and version:

$ sudo systemctl status httpd
Output-
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-06-26 07:13:07 UTC; 11s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 3059 (httpd)
...
$ sudo httpd -v
Output-
Server version: Apache/2.4.6 (rhel)
Server built:   Oct 19 2017 20:39:16

Manage Apache Service:

We can manage apache service in the similar of another systemd services.

To stop httpd service use following command:

$ sudo systemctl stop httpd

To start again httpd service, run following command:

$ sudo systemctl start httpd

To restart apache httpd service, use the following command:

$ sudo systemctl restart httpd

To reload apache httpd web service after any changes, run following command:

$ sudo systemctl reload httpd

To disable apache httpd service to start on boot, use following command:

$ sudo systemctl disable httpd

To enable httpd service again, use below command:

sudo systemctl enable httpd

Apache Configuration File’s Structure

The Apache2 configuration file’s default location is “/etc/httpd/” directory.
 
The main Apache2 web server configuration file is “/etc/httpd/conf/httpd.conf”.
 
The virtual host files configured on Apache webserver stored in the “/etc/httpd/conf.d/” directory. The configuration file ending with “.conf”.
 
The apache web server’s module configuration files stored in the “/etc/httpd/conf.modules.d/” directory.
 
Generally  we can configure all virtual host in a single file, but I suggest to create seperate vhost files.
To troubleshoot or debug the issue with the apache web server, use the log file for apache server and virtual host. The log file for apache located at “/var/log/httpd/access.log” and “/var/log/httpd/error.log”. To make it easy to troubleshoot an issue with different virtual host need to create different access and error log for each virtual host.
 
There is no location boundary to create document root directory, you can create at any location but as per suggestion, the most common location for webroot directory is:
  • /var/www/<site_Name>
  • /var/www/html/<Site_Name>
  • /opt/<site_Name>
  • /home/<user_name>/<Site_Name>

Conclusion

You have learned to install Apache httpd web server on your RHEL 7 server or system. Now your system is ready to deploy a web application using Apache virtual host or use Apache as a web proxy server for your application.

Do you have any doubt, questions or feedback? Feel free to leave a comment.
Satish Kumar

Satish Kumar

I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Related Posts

How to Install MongoDB on RHEL 8 Linux

How to Install MongoDB on RHEL 8 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Install MongoDB on RHEL 7 Linux

How to Install MongoDB on RHEL 7 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

0 Comments

0 Comments

Submit a Comment

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

4 × three =

News & Updates

Join Our Newsletter

Adsense

Adsense

Adsense

Adsense