Installation guide · Apache HTTP Server

How to Install an SSL Certificate on Apache

Install an SSL certificate on Apache in five steps: copy the files, point your virtual host at them, include the full chain, test the config and reload. This guide covers Ubuntu/Debian, RHEL-based systems and Apache on Windows.

How do I install an SSL certificate on Apache?

To install an SSL certificate on Apache, copy your certificate, the CA’s intermediate certificates and your private key to the server, reference them in a <VirtualHost *:443> block with SSLCertificateFile and SSLCertificateKeyFile, then run a config test and reload Apache. Serve the full chain, not just your own certificate, or some clients will reject the connection.

This guide is the Apache-specific part of our overview on how to install an SSL certificate. It assumes the certificate is already issued and you still have the private key from your CSR (certificate signing request, the file you sent to the CA). If you have not created one yet, use our CSR generator or OpenSSL on the server.

ItemWhat you need
Apache version2.4.8 or newer (chain can live in the certificate file)
Modulemod_ssl enabled
FilesServer certificate, intermediate (CA bundle), private key
AccessRoot or sudo (Linux), Administrator (Windows)
Port443 open in the firewall

Installed? Check it from the outside

Run your domain through our free SSL checker to confirm the certificate, the full chain and the expiry date are what browsers see.

Check your Apache SSL setup

Apache SSL certificate installation at a glance

  1. Upload the files

    Copy the certificate, the CA bundle and the private key to a protected directory on the server.

  2. Build the full chain

    Append the intermediate certificate(s) to your server certificate in one PEM file.

  3. Edit the virtual host

    Point SSLCertificateFile and SSLCertificateKeyFile at the new files in the :443 virtual host.

  4. Test, reload, verify

    Run a config test, reload Apache gracefully and check the site from outside.

Step-by-step: install SSL certificate on Apache (Linux)

The commands below use Ubuntu/Debian paths. On RHEL, AlmaLinux or Rocky Linux the service is called httpd and the SSL config lives in /etc/httpd/conf.d/ssl.conf.

1. Upload and protect the files

Your CA delivers the server certificate (for example example_com.crt) and one or more intermediate certificates, often named .ca-bundle or intermediate.crt. Copy them, together with your private key, to the server:

sudo mkdir -p /etc/ssl/example.com
sudo cp example_com.crt example_com.ca-bundle /etc/ssl/example.com/
sudo cp example_com.key /etc/ssl/private/
sudo chmod 600 /etc/ssl/private/example_com.key

Apache needs PEM files: plain text that starts with -----BEGIN CERTIFICATE-----. If you received a .p7b or .pfx file instead, convert it to PEM first; our SSL decoder page explains the formats. Before you edit any config, confirm that the key belongs to the certificate. Both commands must print the same hash:

openssl x509 -noout -pubkey -in example_com.crt | openssl sha256
openssl pkey -pubout -in /etc/ssl/private/example_com.key | openssl sha256

If the hashes differ, the certificate was issued for another CSR. Find the matching key or reissue the certificate with a new CSR.

2. Combine certificate and chain

Since Apache 2.4.8, SSLCertificateFile can hold your certificate followed by the intermediates, and the older SSLCertificateChainFile directive is obsolete. Order matters: your server certificate first, then the intermediates.

cat example_com.crt example_com.ca-bundle > example_com_fullchain.crt

Why the chain matters, and how to fix a broken one, is covered in our guide to the certificate chain.

3. Configure the virtual host

Enable the module (Ubuntu/Debian) and edit the site’s HTTPS virtual host, for example /etc/apache2/sites-available/example.com-ssl.conf:

sudo a2enmod ssl

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com

    SSLEngine on
    SSLCertificateFile    /etc/ssl/example.com/example_com_fullchain.crt
    SSLCertificateKeyFile /etc/ssl/private/example_com.key
</VirtualHost>

Then enable the site with sudo a2ensite example.com-ssl. On RHEL-based systems install the module with sudo dnf install mod_ssl and place the block in a file under /etc/httpd/conf.d/.

4. Test and reload

sudo apachectl configtest
sudo systemctl reload apache2      # RHEL: sudo systemctl reload httpd

A reload applies the new certificate without dropping open connections. Only restart if the reload fails or you just enabled mod_ssl.

Tip: Redirect plain HTTP to HTTPS in the *:80 virtual host with Redirect permanent / https://example.com/ once the HTTPS site works. Do it after testing, not before.

Other setups

  • Apache on Windows

    Same directives, different paths: conf\extra\httpd-ssl.conf and httpd.exe for testing.

  • Wildcard certificates

    Install exactly like a single-domain certificate; one file pair serves every first-level subdomain.

  • Apache Tomcat

    Tomcat is a separate Java server and uses its own connector config, not mod_ssl.

Install SSL certificate on Apache for Windows

On Windows builds of Apache (for example from Apache Lounge), the directives are identical. Open conf\httpd.conf and uncomment these lines:

LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Include conf/extra/httpd-ssl.conf

Then set SSLCertificateFile and SSLCertificateKeyFile in conf\extra\httpd-ssl.conf to your files, using forward slashes (C:/Apache24/conf/ssl/example_com_fullchain.crt). Test with httpd.exe -t and restart the Apache service.

Wildcard certificates and Tomcat

To install a wildcard SSL certificate on Apache, use the same two directives in every virtual host that shares the wildcard; each host can point at the same files. Apache Tomcat configures TLS in conf/server.xml through a <Certificate> element inside <SSLHostConfig>, using a PKCS#12 keystore or PEM files.

Where does Apache store SSL certificate files?

Apache has no certificate store of its own: it reads whatever files the SSLCertificateFile and SSLCertificateKeyFile directives point to. Distributions do ship conventional locations, shown below.

SystemCertificatesPrivate keysSSL config
Ubuntu / Debian/etc/ssl/certs//etc/ssl/private//etc/apache2/sites-available/
RHEL / AlmaLinux / Rocky/etc/pki/tls/certs//etc/pki/tls/private//etc/httpd/conf.d/ssl.conf
Windows (Apache Lounge)any folder, e.g. C:\Apache24\conf\ssl\same folder, restrictedconf\extra\httpd-ssl.conf

To find the files a running site really uses, search the config: grep -Ri "SSLCertificate" /etc/apache2/ (or /etc/httpd/). For IIS, Nginx, Java keystores and desktops, see where certificates are stored on other systems.

Tip: Keep the private key readable by root only (chmod 600). Apache’s parent process reads it as root before dropping privileges.

How do I host several SSL sites on one Apache server?

Give each site its own <VirtualHost *:443> block with its own ServerName and certificate files. Apache uses SNI (Server Name Indication, the hostname the browser sends at the start of the TLS handshake) to pick the matching certificate, so all sites can share one IP address.

<VirtualHost *:443>
    ServerName shop.example.com
    SSLEngine on
    SSLCertificateFile    /etc/ssl/shop/shop_fullchain.crt
    SSLCertificateKeyFile /etc/ssl/private/shop.key
</VirtualHost>

<VirtualHost *:443>
    ServerName blog.example.org
    SSLEngine on
    SSLCertificateFile    /etc/ssl/blog/blog_fullchain.crt
    SSLCertificateKeyFile /etc/ssl/private/blog.key
</VirtualHost>

The first *:443 virtual host Apache loads is the default for clients that send no SNI. Run apachectl -S to list which host answers for which name.

Renew or replace the certificate on Apache

  1. Get the new files

    Download the renewed or reissued certificate and the current CA bundle; if you reissued with a new CSR, use the new key too.

  2. Save them under new names

    Add a date to the file names so you can roll back to the old pair in seconds.

  3. Update the directives

    Point SSLCertificateFile and SSLCertificateKeyFile at the new files, then run apachectl configtest.

  4. Reload and verify

    Reload Apache gracefully and confirm the new expiry date from outside the server.

How do I update an Apache SSL certificate?

Swap the files, update the paths, test, reload. A graceful reload is enough; you do not need downtime. As of October 2026, publicly trusted TLS certificates are valid for at most 200 days, dropping to 100 days on 15 March 2027 under CA/Browser Forum ballot SC-081, so you will repeat this step more often than in the past. When and how to renew an SSL certificate before it expires is covered in its own guide.

Common Apache SSL errors

Error or symptomLikely causeFix
AH02565: Certificate and private key ... do not matchKey from a different CSRUse the key generated with this certificate’s CSR, or reissue
Works in desktop browsers, fails on Android or in curlIntermediate missingAppend the CA bundle to the certificate file
Old certificate still servedWrong virtual host edited, or no reloadCheck apachectl -S, then reload
Apache will not start after the changeWrong path or typo in a directiveRun apachectl configtest and read the line it names
Connection refused on port 443No Listen 443 or firewall closedEnable mod_ssl, open port 443

After any change, run your domain through our SSL checker. It shows the certificate Apache actually serves, whether the chain is complete and when it expires.

Verify your Apache SSL installation

See the served certificate, the complete chain and the expiry date in one check. No login needed.

Run the SSL checker

Related articles

Frequently asked questions

Q: How do I install an SSL certificate on Apache?

A: Copy your certificate, the CA's intermediate certificates and your private key to the server. Combine certificate and intermediates into one file (your certificate first), then reference it with SSLCertificateFile and the key with SSLCertificateKeyFile inside a VirtualHost on port 443. Enable mod_ssl, run apachectl configtest, reload Apache gracefully and check the site with an external SSL checker to confirm the full chain is served.

Q: Where does Apache store SSL certificate files?

A: Apache has no built-in certificate store; it loads the files named in its SSL directives. By convention, Ubuntu and Debian use /etc/ssl/certs and /etc/ssl/private, while RHEL-based systems use /etc/pki/tls/certs and /etc/pki/tls/private. On Windows you choose any folder. Search the configuration for "SSLCertificate" to find the exact files a site uses.

Q: How do I host several SSL sites on one Apache server?

A: Create one VirtualHost on port 443 per site, each with its own ServerName and its own certificate and key files. Apache uses SNI, the hostname the browser sends during the TLS handshake, to choose the matching certificate, so every site can share one IP address. The first loaded port-443 host answers clients without SNI. Use apachectl -S to review the mapping.

Q: How do I renew or replace the certificate on Apache?

A: Save the renewed or reissued certificate and current CA bundle under new file names, and use the new private key if you generated a new CSR. Point SSLCertificateFile and SSLCertificateKeyFile at the new files, run apachectl configtest and reload Apache gracefully, which avoids downtime. Finally, check the domain from outside to confirm the new expiry date and a complete chain.