Apache is one of the most popular web servers in the world, powering millions of websites across the globe. In this tutorial, we’ll walk you through the process of how to install Apache on Rocky Linux, a popular Linux distribution based on the open-source RHEL project. By the end of this guide, you’ll have a fully-functioning Apache web server ready to host your websites and applications.
Table of Contents
- Prerequisites
- Update Your System
- Install Apache
- Configure Apache
- Enable and Start Apache
- Configure Firewall
- Test Apache
- Conclusion
Prerequisites
Before we begin, ensure that you have:
- A system running Rocky Linux
- Root or sudo user access
If you haven’t already, set up a RAID 1 on Rocky Linux for better data protection and redundancy.
How to Install Apache on Rocky Linux
Update Your System
Start by updating your Rocky Linux system to ensure you have the latest packages and security patches. Open a terminal and execute the following commands:
sudo dnf update -y
sudo dnf upgrade -y
Install Apache on Rocky Linux
To install Apache, run the following command:
sudo dnf install httpd -y
During the installation, you may be prompted to import a GPG key. Accept the prompt to proceed with the installation.
Configure Apache on Rocky Linux
Apache’s main configuration file is located at /etc/httpd/conf/httpd.conf
. Open the file using a text editor like Vim:
sudo vim /etc/httpd/conf/httpd.conf
Modify the following lines to suit your needs:
ServerAdmin [email protected]
ServerName www.example.com:80
Replace [email protected]
with your email address and www.example.com
with your domain name.
Enable and Start Apache
Enable the Apache service to start automatically at boot:
sudo systemctl enable httpd
Start the Apache service:
sudo systemctl start httpd
Configure Firewall
To allow incoming traffic to your Apache web server, you need to open the necessary ports on your firewall. If you’re using firewalld
, execute the following commands:
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload
Test Apache
To verify that Apache is running correctly, open your web browser and navigate to your server’s IP address or domain name. You should see the default Apache welcome page.
Conclusion
Congratulations! You’ve successfully installed and configured Apache on your Rocky Linux system. Now you’re ready to host your websites and applications. If you need to install additional software, check out our other tutorials:
- How to Install MySQL on Rocky Linux
- How to Install Nginx on Rocky Linux
- How to Install Python on Rocky Linux
- How to Install phpMyAdmin on Rocky Linux
To further improve your server’s security, consider changing the default SSH port on Rocky Linux by following our guide on how to change the SSH port on Rocky Linux.
If you’re looking to set up a more advanced configuration or integrate additional tools, explore our other tutorials:
- How to Install Git on Rocky Linux
- How to Install and Configure LAMP Stack on Rocky Linux
- How to Set Up a File Server on Rocky Linux
- How to Install FTP Server on Rocky Linux
- How to Set Up an OpenVPN Server on Rocky Linux
We hope this guide has been helpful in getting your Apache web server up and running on Rocky Linux. If you encounter any issues or have questions, don’t hesitate to reach out to the community or refer to the official Apache documentation for more information. Good luck,