Apache HTTP Server Troubleshooting Notes

Field notes from working with the Apache HTTP Server: the commands to validate a configuration before restarting, a common SSLSessionCache misplacement error and its fix, how to read the error log, and the full OpenSSL workflow for installing an SSL certificate and verifying it.

Common Commands

Syntax Check

Additional Options

Issue Encountered: SSLSessionCache cannot occur within <VirtualHost>

Error Description

AH00526: Syntax error on line 209 of /path/to/httpd.conf:
 SSLSessionCache cannot occur within <VirtualHost> section

Cause: The SSLSessionCache directive was placed inside a <VirtualHost> block, which is not allowed. This directive should be in the global context.

Resolution Steps

  1. Open the Apache configuration file for editing:
    vim /path/to/httpd.conf
  2. Locate the SSLSessionCache directive.
  3. Move the directive outside of any <VirtualHost> blocks, typically near the top of the configuration file.
  4. Save and close the file.
  5. Validate the syntax:
    ./httpd -t
  6. Restart the Apache server:
    ./httpd -k restart

Debugging Logs

Check the Error Log

Example logs:

[Fri Jan 10 11:42:11.283516 2025] [ssl:warn] [pid 21313:tid 21313] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
 [Fri Jan 10 12:27:21.218230 2025] [mpm_event:notice] [pid 21414:tid 21414] AH00491: caught SIGTERM, shutting down

Key Warnings and Notices

Tips for Future Troubleshooting

SSL Certificate Creation and Validation

1. Generate a New Private Key

To generate a new private key using OpenSSL:

openssl genrsa -out /opt/apache/key/enum_example_com.key 2048

2. Create a New CSR (Certificate Signing Request)

openssl req -new -key /opt/apache/key/enum_example_com.key -out /opt/apache/key/enum_example_com.csr

3. Submit the CSR to a Certificate Authority (CA)

Once the CSR is generated, submit it to your Certificate Authority (CA) of choice (e.g., Let's Encrypt, DigiCert) to obtain a signed certificate. The CA will provide:

Example — after submitting the CSR you receive files like:

4. Install the SSL Certificate

Edit the Apache configuration to include the following:

SSLEngine On
 SSLCertificateFile /opt/apache/key/enum_example_com.crt
 SSLCertificateKeyFile /opt/apache/key/enum_example_com.key
 SSLCertificateChainFile /opt/apache/key/enum_example_com_chain.crt

Steps to Verify HTTPS Certificate and Redirection

  1. Verify the HTTPS certificate. Run the following command to check the HTTPS certificate:
    curl -ikv https://localhost

    Note: replace localhost with the correct endpoint based on your environment (development or production).

  2. curl -ikv http://localhost checks how the server responds to HTTP requests.
  3. curl -L http://localhost follows any HTTP-to-HTTPS redirections.

Expected Results

Related Articles

A.M. Rinas

Written by A.M. Rinas

Full-Stack Software Engineer working on web applications, DevOps automation, and databases. More about me on the about page, or say hi through the contact page and LinkedIn.

← Back to all articles