Installing SSL Certificates on Ubuntu
Updated: 2026-01-28 07:03:29 Viewed times: 831
Step 1: Upload the Certificate to the Server
First, copy your certificate files to the directory where certificate and key files are stored. Typically, this directory is /etc/ssl/ for your certificate.crt and ca_bundle.crt files, and /etc/ssl/private/ for your private.key file.
Step 2: Adjust the Apache Configuration File
Next, you need to locate the Apache configuration file on your server. Usually, you will find the configuration file in /etc/apache2/sites-enabled/your_site_name.
If you cannot find the configuration file, you can run the following command:
sudo a2ensite your_site_name
After locating the Apache configuration file, you will need to configure the Virtual Host section for the website. Before you do this, make sure to create a backup of the current *.conf file. This way, if anything goes wrong, you will be able to revert any changes.
A typical Virtual Host file looks like this:
DocumentRoot /var/www/site ServerName www.domain.com SSLEngine on SSLCertificateFile /path/to/certificate.crt SSLCertificateKeyFile /path/to/private.key SSLCertificateChainFile /path/to/ca_bundle.crt
The parts highlighted in bold above are the ones you need to edit according to the file paths where your certificate files are located. Make sure the attribute words in bold do not have a “#” (comment) in front of them; if they do, remove that symbol to uncomment them.
As mentioned above, you need to change the file names to match your certificate files and their locations on the server:
-
SSLCertificateFile: This is your primary SSL certificate file (
certificate.crt) -
SSLCertificateChainFile: This is your CA-Bundle file (
ca_bundle.crt) -
SSLCertificateKeyFile: This is your private key file (
private.key)
To verify whether your configuration is valid, you can run the following command:
apachectl configtest
Next, save your Apache configuration file and restart the server using one of the following commands:
apachectl stop
apachectl start
apachectl restart
If you encounter any issues along the way, rest assured that you can restore the Apache configuration file using the backup you created earlier in the process. This will allow you to start over.