🌐 How to Install and Configure Webserver httpd (Apache2) on Rocky Linux 9

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Dear Guest, You are a regular member, and you cannot download files here. To be able to download all files here, you must become a “Lovely Member.” How to become a Lovely Member? Click this link: 💖 How to Become a “Lovely Member” on Our Forum Alternatively, you can upgrade your account to VIP using this link: Upgrade

hrace009

Member
Staff member
Admin
👑 VIP Member
Moderator
Lovely Member
Joined
May 10, 2025
Messages
54
1748822076151.webp


Setting up a reliable web server is the first step toward hosting your own website or application. In this step-by-step guide, you’ll learn how to install and configure Apache (httpd) on Rocky Linux 9, one of the most stable and enterprise-ready distributions based on RHEL.

✅ Prerequisites​

  • A system running Rocky Linux 9
  • A user account with sudo privileges
  • Internet connection

📥 Step 1: Update Your System​

Keep your system up-to-date:
Bash:
sudo dnf update -y

🔧 Step 2: Install Apache (httpd)​

Apache (httpd) is available in the default Rocky Linux 9 repository:
Bash:
sudo dnf install httpd -y
Verify the installation:
Bash:
httpd -v

🚀 Step 3: Enable and Start Apache Service​

Enable Apache to start on boot and start the service:
Bash:
sudo systemctl enable httpd
sudo systemctl start httpd
Check the status:
Bash:
sudo systemctl status httpd

🔥 Step 4: Configure the Firewall​

Allow HTTP and HTTPS traffic:
Bash:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

🧪 Step 5: Test Apache​

Open your browser and go to:
Code:
http://your-server-ip
You should see the Apache test page confirming a successful installation.

🛠️ Step 6: Basic Configuration​

Default Web Root​

Apache's default root directory is:
Code:
/var/www/html
You can place your HTML or PHP files here.

Configuration Files​

Main config file:
Code:
/etc/httpd/conf/httpd.conf
Extra configuration files:
Code:
/etc/httpd/conf.d/

Restart Apache after changes:​

Code:
sudo systemctl restart httpd

🔐 Optional: Secure Apache with SSL (HTTPS)​

Install mod_ssl and generate a self-signed certificate (for testing):
Bash:
sudo dnf install mod_ssl -y
sudo openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/selfsigned.key \
-x509 -days 365 -out /etc/pki/tls/certs/selfsigned.crt
Edit /etc/httpd/conf.d/ssl.conf and point to your certificate and key.
Restart Apache:
Bash:
sudo systemctl restart httpd

📌 Conclusion​

You have successfully installed and configured the Apache web server (httpd) on Rocky Linux 9. You're now ready to host websites, applications, or APIs securely and efficiently.
 
Back
Top