| |

LFCE 50 ๐Ÿง Web Server โ€” Apache Installation

โฑ๏ธ Estimated read: 11 min | |

Apache HTTP Server, commonly called httpd, is the other major web server in the Linux ecosystem. Where the previous chapters covered Nginx as a high-performance static file server and reverse proxy, Apache is a process-based server with a modular architecture, a long history, and a configuration style built on directives inside <Directory>, <VirtualHost>, and <Location> blocks. The installation is a package manager command on both major distribution families, but the package name, the service name, the configuration layout, and the user account all differ between Debian and RHEL.

The previous chapters covered Nginx installation and configuration. This chapter covers the Apache equivalent: the package names, the directory structure, the service management commands, and the firewall rules that make the default “It works!” page reachable from a remote client. It builds the foundation for the virtual host and module configuration that follows.

Key point: The package name and service name differ by distribution. Debian and Ubuntu use apache2 for both the package and the service. RHEL, Rocky Linux, and Fedora use httpd for both. The configuration directory differs as well: /etc/apache2/ on Debian, /etc/httpd/ on RHEL. The web server user is www-data on Debian and apache on RHEL . The service must be started and enabled explicitly on both families, and the firewall must permit HTTP before a remote client can reach the default page.


Why Apache installation requires distribution-specific attention

The package-and-service naming problem.

The Apache HTTP Server is the same software on every distribution, but the packaging conventions differ. On Debian and Ubuntu, the package is apache2, the service unit is apache2.service, and the main binary is /usr/sbin/apache2. On RHEL and its derivatives, the package is httpd, the service unit is httpd.service, and the main binary is /usr/sbin/httpd . An administrator following a Debian tutorial on a RHEL system will run apt install apache2 and receive a command-not-found error. The service management commands use the correct name per family.

The configuration-layout problem.

Debian and Ubuntu use a modular configuration layout inherited from the apache2 package. The main file is /etc/apache2/apache2.conf, which includes ports.conf, mods-enabled/*, conf-enabled/*, and sites-enabled/*. The a2ensite, a2dissite, a2enmod, and a2dismod helper scripts manage the symlinks between the *-available and *-enabled directories . RHEL uses a simpler layout: the main file is /etc/httpd/conf/httpd.conf, and additional configuration fragments are placed in /etc/httpd/conf.d/ and are included automatically . The same virtual host configuration content works on both, but the file placement and the enablement mechanism differ.

The user-account problem.

The Apache worker processes run as an unprivileged user. On Debian and Ubuntu, that user is www-data; on RHEL and its derivatives, it is apache . The DocumentRoot directory and its files must be readable by this user. A web root that is owned by root with restrictive permissions produces a 403 Forbidden response even though the configuration is correct. The chown command must use the correct user for the distribution.


a. Installing on Debian and Ubuntu

The apache2 package is in the default repositories. The installation is two commands: update the package index, then install the package.

# Update the package index
sudo apt update

# Install Apache
sudo apt install apache2 -y

# Verify the installed version
apache2 -v
# Output: Server version: Apache/2.4.58 (Ubuntu)

The package installs the service, starts it automatically, and configures it to start at boot. The systemctl status apache2 command confirms that it is running. The default web root is /var/www/html, and the default page is served from there .

The apache2ctl configtest command validates the configuration syntax before a reload. It is the Apache equivalent of nginx -t and should be run after every configuration change .

# Validate the configuration
sudo apache2ctl configtest
# Output: Syntax OK

b. Installing on RHEL and its derivatives

The httpd package is in the AppStream repository. The installation command uses dnf or yum, and the service must be started explicitly after installation.

# Install Apache
sudo dnf install httpd -y

# Start the service
sudo systemctl start httpd

# Enable the service at boot
sudo systemctl enable httpd

# Verify the installed version
httpd -v
# Output: Server version: Apache/2.4.57 (Red Hat Enterprise Linux)

The RHEL package does not start the service automatically. The systemctl start httpd command starts it, and systemctl enable httpd configures it to start at boot. The combined form systemctl enable --now httpd performs both operations in one command . The default web root is /var/www/html, the same path as on Debian.

The httpd -t command validates the configuration syntax. It reads the main configuration file and all included files, and reports any syntax errors with the file and line number.

# Validate the configuration
sudo httpd -t
# Output: Syntax OK

c. Opening the firewall and verifying the service

The firewall must permit HTTP traffic before a remote client can reach the default page. The command differs between ufw on Debian and firewalld on RHEL.

# Debian/Ubuntu with ufw
sudo ufw allow 'Apache Full'
sudo ufw status

# RHEL/Rocky with firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

The ufw allow 'Apache Full' command opens both port 80 and port 443 using the application profile that the apache2 package installs . The firewall-cmd commands open the http and https services permanently, and --reload applies the changes to the running firewall .

Verification has two parts: confirming that the service is listening on port 80, and confirming that a client can retrieve the default page.

# Confirm Apache is listening on port 80
sudo ss -antpl | grep :80
# Output: LISTEN 0 511 *:80 *:* users:(("apache2",pid=...))

# Test locally with curl
curl -I http://localhost
# Output: HTTP/1.1 200 OK
#         Server: Apache/2.4.58 (Ubuntu)

The ss command confirms that the Apache process has bound to port 80. The curl -I command retrieves the HTTP headers from the local server and confirms that it returns 200 OK. A browser request to the server’s IP address returns the default “It works!” page or the Apache2 default page .


Complete Example Session

# ============================================
# PART 1: UPDATE THE PACKAGE INDEX (DEBIAN)
# ============================================
sudo apt update

# ============================================
# PART 2: INSTALL APACHE
# ============================================
sudo apt install apache2 -y

# ============================================
# PART 3: VERIFY THE INSTALLED VERSION
# ============================================
apache2 -v
# Output: Server version: Apache/2.4.58 (Ubuntu)

# ============================================
# PART 4: CHECK THE SERVICE STATUS
# ============================================
sudo systemctl status apache2
# Output should show "active (running)"

# ============================================
# PART 5: ENABLE THE SERVICE AT BOOT
# ============================================
sudo systemctl enable apache2

# ============================================
# PART 6: OPEN THE FIREWALL (UFW)
# ============================================
sudo ufw allow 'Apache Full'
sudo ufw status
# Output includes: Apache Full ALLOW Anywhere

# ============================================
# PART 7: CONFIRM THE LISTENING PORT
# ============================================
sudo ss -antpl | grep :80
# Output: LISTEN 0 511 *:80

# ============================================
# PART 8: TEST LOCALLY WITH CURL
# ============================================
curl -I http://localhost
# Output: HTTP/1.1 200 OK

# ============================================
# PART 9: TEST FROM A REMOTE CLIENT
# ============================================
# From another machine on the network:
# curl http://<server-ip>
# The default "It works!" page is returned

# ============================================
# PART 10: INSPECT THE DEFAULT CONFIGURATION
# ============================================
ls -l /etc/apache2/
# Output: apache2.conf, ports.conf, sites-available/, sites-enabled/
cat /etc/apache2/sites-enabled/000-default.conf
# The default virtual host listens on port 80 and serves /var/www/html

The ten parts demonstrate the complete installation and verification workflow: package update, installation, version check, service status, boot enablement, firewall opening, port verification, local test, remote test, and configuration inspection. The critical verification steps are Parts 7 and 8: the service must be listening, and it must return a successful HTTP response.


Quick Reference

Installation Commands

DistributionPackageServiceConfig Directory
Debian / Ubuntuapache2apache2/etc/apache2/
RHEL / Rocky / Fedorahttpdhttpd/etc/httpd/

Firewall Commands

FirewallOpen HTTP/HTTPSApply
ufwufw allow 'Apache Full'Automatic
firewalldfirewall-cmd --permanent --add-service=httpfirewall-cmd --reload

Service Management

CommandPurpose
systemctl start apache2 / httpdStart the service
systemctl enable apache2 / httpdStart at boot
systemctl enable --now apache2 / httpdStart and enable
systemctl status apache2 / httpdCheck service state
systemctl reload apache2 / httpdRe-read configuration

Validation Commands

CommandDistributionPurpose
apache2ctl configtestDebianValidate configuration syntax
httpd -tRHELValidate configuration syntax
apache2 -v / httpd -vBothShow installed version
ss -antpl | grep :80BothConfirm listening on port 80

Best Practices

โœ… Do This:

# Use the correct package name for the distribution
apt install apache2    # Debian/Ubuntu                          # โœ…
dnf install httpd      # RHEL/Rocky                             # โœ…

# Enable the service at boot
systemctl enable apache2   # or httpd                           # โœ…

# Open the firewall for HTTP and HTTPS
ufw allow 'Apache Full'    # or firewall-cmd --add-service=http # โœ…

# Validate before reloading
apache2ctl configtest      # or httpd -t                         # โœ…

# Verify the service is listening on port 80
ss -antpl | grep :80                                            # โœ…

# Test with curl before testing from a remote client
curl -I http://localhost                                        # โœ…

โŒ Don’t Do This:

# Use the Debian package name on RHEL
apt install apache2    # Command not found on RHEL              # โŒ

# Assume the service starts automatically on RHEL
# The httpd package does not start the service                   # โŒ

# Forget to reload the firewall after adding the service
firewall-cmd --permanent --add-service=http    # Not active      # โŒ

# Test only from the local host
# A local curl succeeds even if the firewall blocks remote access # โŒ

# Use the wrong web server user for the distribution
chown www-data:www-data /var/www/html    # Wrong on RHEL        # โŒ

Common Pitfalls

PitfallWhy It HappensFix
Command not found on RHELUsed apt or apache2Use dnf install httpd
Service not running after install on RHELRHEL package does not auto-startsystemctl start httpd
Remote client cannot reach the serverFirewall does not permit HTTPOpen port 80 with ufw or firewall-cmd
403 Forbidden on the default pageWeb root permissions wrongchown to www-data or apache
Configuration syntax errorMissing directive or typoapache2ctl configtest or httpd -t
Wrong configuration file editedDistribution uses different layoutDebian: /etc/apache2/; RHEL: /etc/httpd/

Real-World Examples

1. Debian installation

sudo apt update && sudo apt install apache2 -y

2. RHEL installation

sudo dnf install httpd -y

3. Start and enable

sudo systemctl enable --now apache2    # Debian
sudo systemctl enable --now httpd      # RHEL

4. Open ufw

sudo ufw allow 'Apache Full'

5. Open firewalld

sudo firewall-cmd --permanent --add-service=http && sudo firewall-cmd --reload

6. Validate configuration

sudo apache2ctl configtest    # Debian
sudo httpd -t                 # RHEL

7. Check listening port

sudo ss -antpl | grep :80

8. Test locally

curl -I http://localhost

9. Check version

apache2 -v    # Debian
httpd -v      # RHEL

10. Inspect default site

cat /etc/apache2/sites-enabled/000-default.conf    # Debian
cat /etc/httpd/conf/httpd.conf                     # RHEL

Visual

Installation Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  FROM PACKAGE TO REACHABLE WEB SERVER                        โ”‚
โ”‚                                                              โ”‚
โ”‚  Step 1: Install                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ apt install apache2    (Debian)                        โ”‚  โ”‚
โ”‚  โ”‚ dnf install httpd      (RHEL)                          โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 2: Start                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Debian: automatic                                      โ”‚  โ”‚
โ”‚  โ”‚ RHEL:   systemctl start httpd                          โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 3: Enable at boot                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ systemctl enable apache2  (Debian)                     โ”‚  โ”‚
โ”‚  โ”‚ systemctl enable httpd    (RHEL)                       โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 4: Open firewall                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ufw allow 'Apache Full'                                โ”‚  โ”‚
โ”‚  โ”‚ firewall-cmd --add-service=http --permanent            โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 5: Verify                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ss -antpl | grep :80  โ†’ listening                      โ”‚  โ”‚
โ”‚  โ”‚ curl -I http://localhost โ†’ 200 OK                      โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Directory Layout Comparison

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  DEBIAN vs RHEL CONFIGURATION LAYOUT                         โ”‚
โ”‚                                                              โ”‚
โ”‚  Debian / Ubuntu:                                            โ”‚
โ”‚  /etc/apache2/                                               โ”‚
โ”‚  โ”œโ”€โ”€ apache2.conf          โ† Main configuration              โ”‚
โ”‚  โ”œโ”€โ”€ ports.conf            โ† Listening ports                 โ”‚
โ”‚  โ”œโ”€โ”€ mods-available/       โ† All module configs              โ”‚
โ”‚  โ”œโ”€โ”€ mods-enabled/         โ† Active modules (symlinks)       โ”‚
โ”‚  โ”œโ”€โ”€ sites-available/      โ† All site configs                โ”‚
โ”‚  โ””โ”€โ”€ sites-enabled/        โ† Active sites (symlinks)         โ”‚
โ”‚                                                              โ”‚
โ”‚  RHEL / Rocky:                                               โ”‚
โ”‚  /etc/httpd/                                                 โ”‚
โ”‚  โ”œโ”€โ”€ conf/                                                   โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ httpd.conf        โ† Main configuration              โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ conf.d/           โ† Additional configs (auto-loaded)โ”‚
โ”‚  โ””โ”€โ”€ conf.modules.d/       โ† Module loading configs          โ”‚
โ”‚                                                              โ”‚
โ”‚  Debian uses a2ensite/a2enmod. RHEL places files in conf.d.  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Service and Firewall Comparison

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  DEBIAN/UBUNTU vs RHEL/ROCKY                                 โ”‚
โ”‚                                                              โ”‚
โ”‚  Service:                                                    โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Debian: apache2.service                                โ”‚  โ”‚
โ”‚  โ”‚ RHEL:   httpd.service                                  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                              โ”‚
โ”‚  Firewall:                                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ufw (Debian):                                          โ”‚  โ”‚
โ”‚  โ”‚   ufw allow 'Apache Full'                              โ”‚  โ”‚
โ”‚  โ”‚   โ†’ Opens ports 80 and 443                             โ”‚  โ”‚
โ”‚  โ”‚                                                        โ”‚  โ”‚
โ”‚  โ”‚ firewalld (RHEL):                                      โ”‚  โ”‚
โ”‚  โ”‚   firewall-cmd --permanent --add-service=http          โ”‚  โ”‚
โ”‚  โ”‚   firewall-cmd --permanent --add-service=https         โ”‚  โ”‚
โ”‚  โ”‚   firewall-cmd --reload                                โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
Debian packageapache2
RHEL packagehttpd
Debian serviceapache2.service
RHEL servicehttpd.service
Debian config/etc/apache2/apache2.conf
RHEL config/etc/httpd/conf/httpd.conf
Debian web userwww-data
RHEL web userapache
Default web root/var/www/html
Debian firewallufw allow 'Apache Full'
RHEL firewallfirewall-cmd --add-service=http
Validation (Debian)apache2ctl configtest
Validation (RHEL)httpd -t
Listening port80 (HTTP), 443 (HTTPS)

Key takeaways:

  • The package and service names differ by distribution. Debian and Ubuntu use apache2; RHEL and its derivatives use httpd. The service management commands must use the correct name for the family .
  • The configuration layout differs. Debian uses /etc/apache2/ with sites-available and sites-enabled managed by a2ensite and a2dissite. RHEL uses /etc/httpd/ with conf.d/ for additional configuration fragments .
  • The web server user differs. Debian runs Apache workers as www-data; RHEL runs them as apache. The DocumentRoot permissions must be readable by the correct user .
  • The service must be started and enabled. Debian starts the service automatically after installation. RHEL does not. systemctl enable --now performs both the start and the boot enablement.
  • The firewall must permit HTTP. ufw allow 'Apache Full' opens ports 80 and 443 on Debian. firewall-cmd --add-service=http and --add-service=https open the same ports on RHEL .
  • Validate before reloading. apache2ctl configtest on Debian and httpd -t on RHEL catch syntax errors before the new configuration is applied.

Remember: Apache installation is one package command, but the package name, service name, configuration path, and web server user all depend on the distribution. Debian and Ubuntu use apache2, /etc/apache2/, and www-data. RHEL and Rocky use httpd, /etc/httpd/, and apache. Start and enable the service, open the firewall for HTTP and HTTPS, and verify with ss and curl. The default “It works!” page confirms that the server is reachable. The configuration that followsโ€”virtual hosts, modules, and TLSโ€”builds on this foundation.


Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!