← All guides

Programmer’s Reference

Apache

Inspect configuration, understand virtual hosts, and make careful service changes.

Apache 2.4. AlmaLinux commonly uses httpd; Debian/Ubuntu commonly use apache2. Paths, modules, and service names vary.

8 entries · Essentials first · Reviewed October 5, 2026

Glossary: commands, keywords & terms

Select a term for its definition, syntax, example, and common mistakes.

Essentials

Read service status and logs

Read the AlmaLinux Apache unit status and its recent journal messages.

Terminal
systemctl status httpd --no-pager
sudo journalctl -u httpd -n 40 --no-pager

Practical useDiagnose a staging web-service failure without changing state.

Common mistakesUse apache2 on distributions with that service name. Application error logs may be separate from the journal.

Source: www.freedesktop.org documentation (1) · www.freedesktop.org documentation (2) · github.com documentation (3) · github.com documentation (4)

Virtual hosts and access

Define a demo virtual host

Serve a demo document root for a reserved example hostname. Install only in your distribution’s enabled configuration directory.

Apache configuration
<VirtualHost *:80>
    ServerName demo.example.com
    DocumentRoot /srv/demo-site
    <Directory /srv/demo-site>
        Require all granted
        Options -Indexes
        AllowOverride None
    </Directory>
</VirtualHost>

Practical useModel a disposable website without copying production host details.

Common mistakesThis HTTP example does not configure TLS. Filesystem permissions and SELinux must also permit access; do not point it at private configuration.

Source: httpd.apache.org documentation (1) · httpd.apache.org documentation (2)

Directory access rules

Deny HTTP access to a private directory explicitly.

Apache configuration
<Directory /srv/demo-site/private>
    Require all denied
</Directory>

Practical useProtect a demo directory while designing public/private boundaries.

Common mistakesThis does not prevent local access and cannot undo access through another alias. Prefer storing secrets outside the document root.

Source: httpd.apache.org documentation

Routing and headers

Rewrite rules and context

In a demo .htaccess file, redirect an old path to a new path temporarily.

⚠ Caution: Changes routing; a wrong redirect can make pages inaccessible.

Apache configuration
RewriteEngine On
RewriteRule ^old-guide/?$ /reference/ [R=302,L]

Practical useTest a public reference redirect in staging.

Common mistakesIn .htaccess, the matched path has no leading slash. mod_rewrite and suitable AllowOverride are required. Use a temporary redirect while testing.

Source: httpd.apache.org documentation

Set a response header

Use mod_headers to set a basic MIME-sniffing protection header.

Apache configuration
Header always set X-Content-Type-Options "nosniff"

Practical useServe a demo reference’s assets with their correct types.

Common mistakesmod_headers must be loaded. Correct MIME types are still necessary; test scripts and styles after header changes.

Source: httpd.apache.org documentation

Service changes

Reload versus restart

After a successful configuration check, reload the AlmaLinux service configuration, then inspect status.

⚠ Caution: Applies live configuration and can affect requests; restart interrupts the service.

Terminal
sudo apachectl configtest && sudo systemctl reload httpd
systemctl status httpd --no-pager

Practical useUse the established application service controls for live changes; practice this sequence on staging.

Common mistakesA failed validation must stop the change. reload support depends on the unit; restart stops and starts the service and may interrupt requests.

Source: httpd.apache.org documentation (1) · www.freedesktop.org documentation (2) · github.com documentation (3)

Back to top ↑