Loading...

Knowledge Base

How to Install Certificates on Apache Open SSL

Securing your Apache server with an SSL certificate is essential for encrypting data and protecting your visitors. This guide provides a detailed walkthrough for installing your certificate files and configuring your server for a secure connection.

This process involves four main phases:

Phase 1: Prerequisites - Copying Certificate Files

  1. Download your Intermediate and Primary Certificate files.
  2. Copy these files to the directory on your server where you store your certificate and key files (e.g., `/etc/ssl/certs/`).
  3. Ensure that these files are only readable by the root user to maintain security.

Phase 2: Locating and Configuring the Apache File

You need to find and edit your Apache configuration file (config file) to point to your new certificate files.

Where is the Apache config file?

The file location and name can vary. The main file is often named `httpd.conf` or `apache2.conf`, located in `/etc/httpd/` or `/etc/apache2/`. SSL-specific configurations are commonly found in a `` block within a separate file, such as `httpd-ssl.conf`, or in directories like `/etc/httpd/sites/` or `/etc/httpd/vhosts.d/`.

  1. Locate the correct `` block. You need to edit the virtual host block for your site that is configured for port **443** (the standard SSL port).
  2. Configure the VirtualHost block. Add or update the following directives within the `` block to point to your specific certificate files.

    Below is an example of a configured block:


    DocumentRoot /var/www/html
    ServerName www.yourdomain.com
    SSLEngine on
    SSLCertificateFile /path/to/your_domain_name.crt
    SSLCertificateKeyFile /path/to/your_private.key
    SSLCertificateChainFile /path/to/intermediate_certificate.crt
  3. Verify the file names:
    • SSLCertificateFile: This should be your primary certificate file (e.g., `your_domain_name.crt`).
    • SSLCertificateKeyFile: This should be the private key file generated when you created your CSR.
    • SSLCertificateChainFile: This should be the intermediate certificate file. If this directive doesn't work, some older Apache versions use `SSLCACertificateFile` instead.

Phase 3: Testing Your Configuration

Before restarting your server, it's crucial to test your configuration files for any syntax errors. Apache will fail to start if errors are present.

  1. Run the following command from your terminal: apachectl configtest
  2. If the command returns **Syntax OK**, you are ready to restart. If it returns an error, review your configuration file for typos or incorrect paths.

Phase 4: Restarting Apache

Once your configuration is correct, you must restart Apache to apply the changes.

  1. Use the following commands to stop and start your server: apachectl stop apachectl start
Note on SSL Support: If Apache starts but SSL is not working, try using `apachectl startssl`. If this works, you may need to adjust your server's startup configuration to load SSL support by default.

Review

By following this guide, you have successfully copied your certificate files to your server, configured your Apache virtual host to use them, tested the configuration for errors, and restarted the server. Your Apache server is now configured to provide a secure, encrypted connection to your visitors.

Did you find this article helpful?

 
* Your feedback is too short

Loading...