DigiCert KnowledgeBase - Technical Support-hero

Knowledge Base

How to create a CSR using OpenSSL & install your SSL certificate on an Apache server

Solution ID : TL48
Last Modified : 02/19/2025

Use the instructions on this page to use OpenSSL to create your certificate signing request (CSR) and install your SSL certificate on your Apache server.

Restart Note: After you've installed your SSL/TLS certificate and configured the server to use it, you must restart your Apache instance.

For Ubuntu instructions, see Ubuntu Server with Apache2: Create CSR & Install SSL Certificate (OpenSSL). For other OS/platform instructions, see Create a CSR (Certificate Signing Request).

You can use these instructions to create OpenSSL CSRs and install all types of DigiCert SSL certificates on your Apache server: Standard SSL, EV SSL, Multi-Domain SSL, EV Multi-Domain SSL, and Wildcard SSL.

 

  1. To create your certificate signing request (CSR), see Apache: Creating Your CSR with OpenSSL.
    Para un tutorial en español visite la página Apache Crear CSR.
  2. To install your SSL certificate, see Apache: Installing & Configuring Your SSL Certificate.
    Visite nuestras instrucciones en español para Apache Instalar Certificado SSL.

Apache: Creating Your CSR with OpenSSL

Use the instructions in this section to create your shell commands to generate your Apache CSR with OpenSSL.

Recommended: Save yourself some time. Use the DigiCert OpenSSL CSR Wizard to generate an OpenSSL command to create your Apache CSR. Just fill out the form, click Generate, and paste your customized OpenSSL command into your terminal.

How to Generate a CSR for Apache Using OpenSSL

If you prefer to build your shell commands to generate your Apache CSR, follow the instructions below.

  1. Log in to your server via your terminal client (ssh).
  2. Run Command
    At the prompt, type the following command:

    openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

    Note:
     Make sure to replace server with the name of your server.

  3. Generate Files
    1. You've now started the process for generating the following two files:
      • Private-Key File: Used to generate the CSR and later to secure and verify connections using the certificate.
      • Certificate Signing Request (CSR) file: Used to order your SSL certificate and later to encrypt messages that only its corresponding private key can decrypt
    2. When prompted for the Common Name (domain name), type the fully qualified domain (FQDN) for the site that you are going to secure.

      Note: If you're generating an Apache CSR for a Wildcard certificate, make sure your common name starts with an asterisk (e.g., *.example.com).

    3. When prompted, type your organizational information, beginning with your geographic information.

      Note: You may have already set up default information.

    4. Now, your OpenSSL .csr file is created.

  4. Order Your SSL/TLS Certificate
    1. Open the .csr file you created with a text editor.
    2. Copy the text, including the -----BEGIN NEW CERTIFICATE REQUEST----- and -----END NEW CERTIFICATE REQUEST----- tags, and paste it into the DigiCert order form.
  5. Save Private Key
    Save (back up) the generated .key file. You need it later to install your SSL certificate
  6. Install Certificate
    After you've received your SSL certificate from DigiCert, you can install it on your server.

INCREASE TRUST IN YOUR APPS AND CODE WITH A DIGICERT CODE SIGNING CERTIFICATE.

Apache: Installing & Configuring Your SSL Certificate

If you still need to create a certificate signing request (CSR) and order your certificate, see Apache: Creating Your CSR with OpenSSL.

After we've validated and issued your SSL certificate, you can install it on your Apache server (where the CSR was generated) and configure the server to use the certificate.

How to Install and Configure Your SSL Certificate on Your Apache Server

  1. Copy the certificate files to your server.
    1. Log in to your DigiCert account and download the intermediate (DigiCertCA.crt) and your primary certificate (your_domain_name.crt) files.
    2. Copy these files, along with the .key file you generated when creating the CSR, to the directory on the server where you keep your certificate and key files.

      Note:
       Make them readable by root only to increase security.
       
  2. Find the Apache configuration file (httpd.conf) you need to edit.
    The location and name of the configuration file can vary from server to server—especially if you're using a special interface to manage your server configuration. 
    • Apache's main configuration file is typically named httpd.conf or apache2.conf. Possible locations for this file include /etc/httpd/ or /etc/apache2/. For a comprehensive listing of default installation layouts for Apache HTTPD on various operating systems and distributions, see Httpd Wiki - DistrosDefaultLayout.
    • Often, the SSL certificate configuration is located in a <VirtualHost> block in a different configuration file. The configuration files may be under a directory like /etc/httpd/vhosts.d//etc/httpd/sites/, or in a file called httpd-ssl.conf.

      One way to locate the SSL Configuration on Linux distributions is to search using grep, as shown in the example below.

      Run the following command:

      Note: Make sure to replace /etc/httpd/ with the base directory for your Apache installation.

    • Identify the SSL <VirtualHost> block you need to configure.

      If your site needs to be accessible through both secure (https) and non-secure (http) connections, you need a virtual host for each type of connection. Make a copy of the existing non-secure virtual host and configure it for SSL as described in step 4.

      If your site only needs to be accessed securely, configure the existing virtual host for SSL as described in step 4.

    •