backbone
cassandra
rocket
+
+
โ‰ˆ
gcp
+
+
+
zig
+
firebase
torch
>=
preact
sinatra
+
+
aurelia
+
+
rest
+
mongo
+
https
firebase
mint
scheme
junit
+
+
packer
+
+
+
+
tcl
+
+
+
+
graphdb
centos
+
+
android
xcode
+
+
echo
+
+
+
+
+
+
laravel
+
sublime
crystal
astro
+
+
+
gin
โˆ‚
pytest
k8s
+
d
abap
+
+
+
strapi
py
prometheus
+
+
nuxt
+
torch
k8s
react
+
dns
โˆ‰
argocd
Back to Blog
๐ŸŒ Apache Web Server Installation on AlmaLinux: Complete Setup Guide
Apache Installation Web Server Setup AlmaLinux Web Hosting

๐ŸŒ Apache Web Server Installation on AlmaLinux: Complete Setup Guide

Published Sep 14, 2025

Install and configure Apache HTTP Server on AlmaLinux with this comprehensive step-by-step guide. Learn virtual hosts, SSL setup, performance tuning, and security hardening for web hosting success.

18 min read
0 views
Table of Contents

๐ŸŒ Apache Web Server Installation on AlmaLinux: Complete Setup Guide

Ready to power your websites with the worldโ€™s most popular web server? ๐Ÿš€ Today weโ€™ll install and configure Apache HTTP Server on AlmaLinux - the backbone of over 30% of all websites worldwide! Whether youโ€™re hosting a personal blog, business website, or enterprise application, this guide makes Apache setup simple and secure! ๐ŸŽฏ

๐Ÿค” Why is Apache on AlmaLinux Important?

Apache HTTP Server on AlmaLinux delivers incredible benefits:

  • ๐Ÿ“Œ Worldโ€™s #1 web server - Powers millions of websites including major enterprises
  • ๐Ÿ”ง Enterprise stability - Rock-solid performance with AlmaLinuxโ€™s reliability
  • ๐Ÿš€ Free and open source - No licensing costs, complete freedom
  • ๐Ÿ” Advanced security - SSL/TLS support and comprehensive security modules
  • โญ Perfect flexibility - Supports PHP, Python, Perl, and virtually any web technology

๐ŸŽฏ What You Need

Before installing Apache on AlmaLinux:

  • โœ… AlmaLinux 9 system (server or desktop)
  • โœ… Root or sudo access
  • โœ… At least 1GB RAM (2GB+ recommended for production)
  • โœ… 5GB+ free disk space
  • โœ… Basic command line knowledge (weโ€™ll guide you!)

๐Ÿ“ Step 1: Install Apache Web Server

Letโ€™s get Apache installed and running! ๐Ÿ› ๏ธ

Update System and Install Apache

# Update system packages first
sudo dnf update -y

# Install Apache HTTP Server
sudo dnf install -y httpd

# Install additional useful Apache modules
sudo dnf install -y httpd-tools httpd-manual

# Verify Apache installation
httpd -v
# Apache/2.4.53 (AlmaLinux)

# Check installed Apache modules
httpd -M | head -10

echo "โœ… Apache HTTP Server installed successfully!"

Start and Enable Apache Service

# Start Apache service
sudo systemctl start httpd

# Enable Apache to start at boot
sudo systemctl enable httpd

# Check Apache service status
sudo systemctl status httpd

# Verify Apache is listening on port 80
sudo ss -tlnp | grep :80

# Test Apache from command line
curl -I http://localhost

echo "โœ… Apache web server is running on port 80!"

Pro tip: ๐Ÿ’ก Apache automatically creates the /var/www/html directory for your website files!

๐Ÿ”ง Step 2: Configure Firewall for Web Traffic

Allow HTTP and HTTPS traffic through the firewall:

Open Web Ports in Firewall

# Allow HTTP traffic (port 80)
sudo firewall-cmd --permanent --add-service=http

# Allow HTTPS traffic (port 443)
sudo firewall-cmd --permanent --add-service=https

# Alternative: Allow specific ports
# sudo firewall-cmd --permanent --add-port=80/tcp
# sudo firewall-cmd --permanent --add-port=443/tcp

# Reload firewall to apply changes
sudo firewall-cmd --reload

# Verify firewall rules
sudo firewall-cmd --list-services

# Check if ports are open
sudo firewall-cmd --query-service=http
sudo firewall-cmd --query-service=https

echo "โœ… Firewall configured for web traffic!"

Test Apache Access

# Get server IP address
IP_ADDRESS=$(ip route get 1.1.1.1 | awk '{print $7; exit}')
echo "Your server IP: $IP_ADDRESS"

# Test from local machine
curl -I http://localhost

# Test Apache default page
curl http://localhost

# Access from browser
echo "Open browser and visit: http://$IP_ADDRESS"
echo "You should see the Apache test page!"

echo "โœ… Apache is accessible from the web!"

๐ŸŒŸ Step 3: Create Your First Website

Set up your website with custom content:

Create Website Content

# Navigate to web root directory
cd /var/www/html

# Create a sample homepage
sudo tee index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome to My AlmaLinux Server</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 50px; background: #f4f4f4; }
        .container { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
        h1 { color: #2c3e50; }
        .info { background: #ecf0f1; padding: 15px; border-radius: 5px; margin: 20px 0; }
    </style>
</head>
<body>
    <div class="container">
        <h1>๐Ÿš€ Welcome to My AlmaLinux Apache Server!</h1>
        <p>Congratulations! Apache HTTP Server is running successfully on AlmaLinux.</p>
        <div class="info">
            <h3>Server Information</h3>
            <p><strong>OS:</strong> AlmaLinux 9</p>
            <p><strong>Web Server:</strong> Apache HTTP Server</p>
            <p><strong>Status:</strong> โœ… Online and Ready!</p>
        </div>
        <p>You can now upload your website files to <code>/var/www/html</code></p>
    </div>
</body>
</html>
EOF

# Create a simple PHP info page
sudo tee info.php << 'EOF'
<?php
// PHP Information Page
phpinfo();
?>
EOF

# Set proper ownership and permissions
sudo chown -R apache:apache /var/www/html
sudo chmod -R 644 /var/www/html/*
sudo find /var/www/html -type d -exec chmod 755 {} \;

# Test the new website
curl http://localhost

echo "โœ… Custom website created successfully!"

Install PHP Support (Optional)

# Install PHP and common modules
sudo dnf install -y php php-cli php-fpm php-mysqlnd php-curl php-gd php-mbstring php-xml

# Restart Apache to load PHP
sudo systemctl restart httpd

# Test PHP functionality
curl http://localhost/info.php

# Remove PHP info file for security
sudo rm /var/www/html/info.php

echo "โœ… PHP support added to Apache!"

โœ… Step 4: Configure Apache Virtual Hosts

Set up multiple websites on one server:

Create Virtual Host Directory Structure

# Create directories for virtual hosts
sudo mkdir -p /var/www/example.com/html
sudo mkdir -p /var/www/testsite.local/html
sudo mkdir -p /etc/httpd/sites-available
sudo mkdir -p /etc/httpd/sites-enabled

# Create sample content for first site
sudo tee /var/www/example.com/html/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
    <title>Example.com - Powered by Apache on AlmaLinux</title>
</head>
<body>
    <h1>๐ŸŒŸ Welcome to Example.com</h1>
    <p>This is the first virtual host on our Apache server!</p>
    <p>Server powered by AlmaLinux and Apache HTTP Server</p>
</body>
</html>
EOF

# Create sample content for second site
sudo tee /var/www/testsite.local/html/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
    <title>Test Site - Apache Virtual Host</title>
    <style>body { background-color: #e8f4f8; font-family: Arial; }</style>
</head>
<body>
    <h1>๐Ÿงช Test Site Virtual Host</h1>
    <p>This is a second website on the same Apache server!</p>
    <p>Multiple sites, one powerful AlmaLinux server โšก</p>
</body>
</html>
EOF

echo "โœ… Virtual host directories and content created!"

Configure Virtual Host Files

# Create virtual host configuration for example.com
sudo tee /etc/httpd/sites-available/example.com.conf << 'EOF'
<VirtualHost *:80>
    # Server identification
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/html
    
    # Logging
    ErrorLog /var/log/httpd/example.com_error.log
    CustomLog /var/log/httpd/example.com_access.log combined
    
    # Directory permissions
    <Directory /var/www/example.com/html>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF

# Create virtual host configuration for testsite.local
sudo tee /etc/httpd/sites-available/testsite.local.conf << 'EOF'
<VirtualHost *:80>
    # Server identification
    ServerName testsite.local
    ServerAlias www.testsite.local
    DocumentRoot /var/www/testsite.local/html
    
    # Logging
    ErrorLog /var/log/httpd/testsite.local_error.log
    CustomLog /var/log/httpd/testsite.local_access.log combined
    
    # Directory permissions
    <Directory /var/www/testsite.local/html>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF

# Enable virtual hosts by creating symbolic links
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/
sudo ln -s /etc/httpd/sites-available/testsite.local.conf /etc/httpd/sites-enabled/

# Set proper ownership
sudo chown -R apache:apache /var/www/

# Test Apache configuration
sudo httpd -t

# Restart Apache to load virtual hosts
sudo systemctl restart httpd

echo "โœ… Virtual hosts configured successfully!"

๐ŸŽฎ Quick Examples

Example 1: Complete WordPress Setup ๐ŸŒ

# Complete LAMP stack with WordPress
echo "=== Setting up WordPress on Apache ===="

# Create WordPress virtual host
sudo mkdir -p /var/www/myblog.com/html

# Download WordPress (for demo - use proper download in production)
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz

# Move WordPress files
sudo cp -R wordpress/* /var/www/myblog.com/html/

# Set permissions
sudo chown -R apache:apache /var/www/myblog.com
sudo chmod -R 755 /var/www/myblog.com

# Create virtual host for WordPress
sudo tee /etc/httpd/sites-available/myblog.com.conf << 'EOF'
<VirtualHost *:80>
    ServerName myblog.com
    ServerAlias www.myblog.com
    DocumentRoot /var/www/myblog.com/html
    
    # PHP and WordPress optimizations
    php_admin_value memory_limit 256M
    php_admin_value max_execution_time 300
    php_admin_value upload_max_filesize 64M
    
    # Security headers
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
    
    ErrorLog /var/log/httpd/myblog.com_error.log
    CustomLog /var/log/httpd/myblog.com_access.log combined
    
    <Directory /var/www/myblog.com/html>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF

# Enable the site
sudo ln -s /etc/httpd/sites-available/myblog.com.conf /etc/httpd/sites-enabled/
sudo systemctl restart httpd

echo "โœ… WordPress site configured!"
echo "Visit: http://myblog.com (add to /etc/hosts for testing)"

Example 2: SSL/HTTPS Configuration ๐Ÿ”’

# Set up SSL with self-signed certificates (for testing)
echo "=== Setting up SSL/HTTPS Support ==="

# Install SSL module
sudo dnf install -y mod_ssl openssl

# Generate self-signed certificate (for testing only)
sudo mkdir -p /etc/ssl/private /etc/ssl/certs

# Create SSL certificate
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/ssl/private/apache-selfsigned.key \
    -out /etc/ssl/certs/apache-selfsigned.crt \
    -subj "/C=US/ST=State/L=City/O=Organization/OU=IT Department/CN=example.com"

# Create strong Diffie-Hellman group
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

# Create SSL virtual host
sudo tee /etc/httpd/sites-available/example.com-ssl.conf << 'EOF'
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/html
    
    # SSL Configuration
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
    
    # Modern SSL configuration
    SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
    SSLHonorCipherOrder off
    
    # Security headers
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
    Header always set X-Frame-Options DENY
    Header always set X-Content-Type-Options nosniff
    
    # Logging
    ErrorLog /var/log/httpd/example.com_ssl_error.log
    CustomLog /var/log/httpd/example.com_ssl_access.log combined
    
    <Directory /var/www/example.com/html>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
</IfModule>
EOF

# Enable SSL site
sudo ln -s /etc/httpd/sites-available/example.com-ssl.conf /etc/httpd/sites-enabled/
sudo systemctl restart httpd

# Test SSL
curl -k -I https://localhost

echo "โœ… SSL/HTTPS configured!"
echo "Visit: https://example.com (ignore certificate warning for self-signed)"

Example 3: Apache Performance Optimization โšก

# Optimize Apache for better performance
echo "=== Apache Performance Tuning ==="

# Create performance configuration
sudo tee /etc/httpd/conf.d/performance.conf << 'EOF'
# Performance Optimizations for Apache

# Enable compression
LoadModule deflate_module modules/mod_deflate.so
<Location />
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
</Location>

# Browser caching
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/ico "access plus 1 month"
    ExpiresByType image/icon "access plus 1 month"
    ExpiresByType text/html "access plus 1 hour"
</IfModule>

# Security and performance headers
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    
    # Remove server signature
    Header always unset Server
    Header always unset X-Powered-By
</IfModule>

# Hide Apache version
ServerTokens Prod
ServerSignature Off

# Connection limits and timeouts
Timeout 60
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

# Worker limits (adjust based on your server resources)
<IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 20
    MaxRequestWorkers 150
    MaxConnectionsPerChild 1000
</IfModule>
EOF

# Enable required modules
sudo dnf install -y httpd-devel
sudo systemctl restart httpd

# Test performance optimizations
curl -H "Accept-Encoding: gzip" -I http://localhost

# Monitor Apache performance
echo "Monitor with: sudo tail -f /var/log/httpd/access_log"

echo "โœ… Apache performance optimized!"

๐Ÿšจ Fix Common Problems

Problem 1: Apache Wonโ€™t Start โŒ

Symptoms:

  • Service fails to start
  • Port 80 already in use error

Try this:

# Check if another service is using port 80
sudo ss -tlnp | grep :80

# Check for configuration errors
sudo httpd -t

# Check Apache error logs
sudo tail -n 50 /var/log/httpd/error_log

# Kill processes using port 80 if needed
sudo fuser -k 80/tcp

# Check SELinux issues
sudo setsebool -P httpd_can_network_connect 1

# Start Apache in foreground for debugging
sudo httpd -D FOREGROUND

Problem 2: Permission Denied Errors โŒ

Try this:

# Fix file ownership
sudo chown -R apache:apache /var/www/html

# Fix file permissions
sudo find /var/www/html -type f -exec chmod 644 {} \;
sudo find /var/www/html -type d -exec chmod 755 {} \;

# Check SELinux contexts
sudo restorecon -Rv /var/www/html

# Allow Apache to read user content
sudo setsebool -P httpd_enable_homedirs 1

# Check Apache user and group
grep -E '^User|^Group' /etc/httpd/conf/httpd.conf

Problem 3: Virtual Hosts Not Working โŒ

Check these things:

# Test Apache configuration
sudo httpd -t

# Check if sites are enabled
ls -la /etc/httpd/sites-enabled/

# Verify DNS or host file entries
cat /etc/hosts

# Check virtual host logs
sudo tail -f /var/log/httpd/*error.log

# Test with curl specifying host header
curl -H "Host: example.com" http://localhost

# Restart Apache after changes
sudo systemctl restart httpd

๐Ÿ“‹ Simple Commands Summary

TaskCommand
๐Ÿ”ง Install Apachesudo dnf install httpd
๐Ÿš€ Start Apachesudo systemctl start httpd
โ™ป๏ธ Restart Apachesudo systemctl restart httpd
๐Ÿ“Š Check statussudo systemctl status httpd
๐Ÿงช Test configsudo httpd -t
๐Ÿ“ View error logssudo tail -f /var/log/httpd/error_log
๐ŸŒ Test locallycurl http://localhost

๐Ÿ’ก Tips for Success

  1. Always test configurations ๐ŸŒŸ - Use httpd -t before restarting
  2. Monitor log files ๐Ÿ” - Check error logs for troubleshooting
  3. Use virtual hosts ๐Ÿš€ - Organize multiple sites properly
  4. Enable SSL/HTTPS ๐Ÿ“ - Secure your websites with encryption
  5. Regular backups ๐Ÿ”„ - Backup your configuration and website files

๐Ÿ† What You Learned

Congratulations! Now you can:

  • โœ… Install and configure Apache HTTP Server on AlmaLinux
  • โœ… Set up virtual hosts for multiple websites
  • โœ… Configure SSL/HTTPS for secure connections
  • โœ… Optimize Apache performance for better speed
  • โœ… Troubleshoot common Apache server issues

๐ŸŽฏ Why This Matters

Your Apache server on AlmaLinux provides:

  • ๐Ÿš€ Professional web hosting ready for production websites
  • ๐Ÿ” Secure foundation with SSL support and security modules
  • ๐Ÿ“Š Scalable performance that grows with your traffic needs
  • โšก Reliable platform for hosting multiple websites and applications

Remember: Apache HTTP Server powers over 30% of all websites on the internet - with proper setup and maintenance, it will serve your websites reliably for years! From simple blogs to complex e-commerce sites, you now have the foundation for any web project! โญ

Youโ€™ve successfully mastered Apache installation and configuration on AlmaLinux! Your web server is now ready to host websites, applications, and services with enterprise-grade reliability and performance! ๐Ÿ™Œ