This article will demonstrate how to install apache for linux. Specifically, this article will focus on how to install apache on RHEL 8.x. Apache is otherwise known as httpd, so these instructions are the same for installing httpd on linux.
These instructions assume you have root access to the server.
Step #1: Install apache
To install apache from the command line on Redhat, run the following set of commands.
dnf install httpd
After the installation is complete, you should enable and start httpd.
systemctl enable httpd systemctl start httpd
Check your httpd version with the following command. It should be the latest version available in your package manager.
The output should be similar to the output below.
Server version: Apache/2.4.37 (Red Hat Enterprise Linux) Server built: Jul 28 2022 23:43:33
On Redhat, the default firewall behavior is to block traffic on port 80. You will need to manually allow traffic by opening up your firewall with just a couple of commands. Read our other post on managing the firewall on Redhat.
firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --reload
Next, create your index.html file to be displayed in your apache instance.
echo Hello World > /var/www/html/index.html
That’s it! You have successfully installed apache for Linux on Redhat. You can access the web page you previously created at http://server.name. Let us know in the comments if you have any questions or would like to see more examples of how to install apache or maintain apache on Linux. Read more of our content here.
Leave a Reply