Install an SSL certificate on a VPS
This guide explains how to install a certificate on a web server on your VPS, with the chain in the right place, and how to check the result.
This page is for an origin HTTPS listener, such as direct public hosting. A loopback HTTP origin does not need a separate origin certificate.
Before you begin
- A VPS with access, and a web server already running. See Web server setup.
- The issued certificate, the intermediate chain, and the private key from your order or CSR.
- For direct public hosting, DNS points to the VPS and its public HTTPS port is reachable.
- Root or sudo access, used with care. See SSH keys and root access.
Protect the private key on the server
Set the key file so that only the root user can read it. Do not leave copies in your home folder or in a public folder. Do not share the key by email or chat.
Steps
The commands below are for a server running Nginx on a typical Linux system. Paths can differ, so check your web server's documentation first.
Copy the certificate file, the chain file and the private key to a folder that only root can read, such as
/etc/ssl/yourdomain/.Set the key file's permissions:
bashsudo chmod 600 /etc/ssl/yourdomain/yourdomain.keyCombine the certificate and the chain into one file if your web server needs that:
bashsudo sh -c 'cat /etc/ssl/yourdomain/yourdomain.crt /etc/ssl/yourdomain/chain.crt > /etc/ssl/yourdomain/fullchain.crt'In the server block for your domain, set the certificate and key paths, and enable port 443 with SSL.
Test the web server configuration before you reload it:
bashsudo nginx -tReload the web server if the test passes:
bashsudo systemctl reload nginxOpen
https://yourdomain.comin a browser and check the padlock.
Expected result
The configuration test passes, the site opens over HTTPS, and the browser shows a valid certificate for the domain.
If something goes wrong
- The configuration test fails. Read the error line it shows. It usually names the file or line that is wrong.
- The browser warns about the chain. Use the combined
fullchainfile, then reload and test again. - Port 443 is blocked. Check the firewall rules you have set. Do not disable the firewall to test. See Updates and firewall.
Related articles
Last reviewed
2026-10-28
