How do I install an SSL certificate on a VPS via command line?

In order to install a SSL certificate, make sure your plan includes a dedicated IP address. If it does not, contact us so we can assist you with adding one to your account.

First, make sure mod_ssl is installed. In Centos you can run the following command to install mod_ssl:

On Centos: yum install mod_ssl

On Ubuntu: a2enmod ssl

Restart Apache.

To install the SSL certificate follow these steps:

  • Create a file /etc/httpd/conf.d/cert.key and place the content of the certificate key in it. It will look like (with more lines):

-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDsvYWqOtJBR+j15pCITwyM48Cp3rBArdJOsOjoFrU2CXiDpYAb
4ZiA3CD+wTQtod+3aeRTAkEAuXfD0NSgcTYsqHS+HHUyDZifrjZBPhBNL4ONAvof
ReXZzngKgFTGhfUm0Ypu6QVTRHit+Miv+AyY72KCUsN4/A==
-----END RSA PRIVATE KEY-----

Create a file /etc/httpd/conf.d/cert.crt and place the content of the certificate in it. It will look like (with more lines):

-----BEGIN CERTIFICATE-----
MIIDODCCAqGgAwIBAgIDC+KlMA0GCSqGSIb3DQEBBQUAME4xCzAJBgNVBAYTAlVT
MRAwDgYDVQQKEwdFcXVpZmF4MS0wKwYDVQQLEyRFcXVpZmF4IFNlY3VyZSBDZXJ0
UeHR9A2VwXvIbcrxYoLLFZraqI56CNwRCNIsUB9Z9k+6Y0J+A2iRo75Ws2cHPAMc
97keASGvyDZy1w9W
-----END CERTIFICATE-----

  • Edit /etc/httpd/conf.d/ssl.conf (centos) or /etc/apache2/sites-enabled/default-ssl (ubuntu) and change SSLCertificateKeyFile and SSLCertificateFile directives so they point to the files listed in 1 and 2.

SSLCertificateFile /etc/httpd/conf.d/cert.crt
SSLCertificateKeyFile /etc/httpd/conf.d/cert.key

Restart apache by running service httpd restart or in the control panel.

Related Articles

Installing an SSL certificate — complete guide for VPS
How do I install an SSL certificate on a VPS using the control panel?