- Joined
- May 10, 2025
- Messages
- 54
- Thread Author
- #1
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
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
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
Step 6: Basic Configuration
Default Web Root
Apache's default root directory is:
Code:
/var/www/html
Configuration Files
Main config file:
Code:
/etc/httpd/conf/httpd.conf
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
/etc/httpd/conf.d/ssl.conf and point to your certificate and key.Restart Apache:
Bash:
sudo systemctl restart httpd