How to Install a Digital Ocean SSL certificate
Ok, you just bought your first hosting package from one of the leading providers of VPS and website hosting server technology. What comes next? Well, first of all, it’s a good idea to protect your site and log in with an SSL certificate. Fortunately, doing this isn’t too hard for DO. It can be tricky for beginners, but persevere, and you’ll be able to install one successfully with the help of this article.
Determine if your web server uses software such as Apache or Nginx. They are the two best choices for serving your consent via web hosting. They differ in architecture and management, but fundamentally, they work similarly. The most popular choice is Apache, although Nginx can offer speed performance enhancements.
How to install an Apache web server SSL certificate
Obtaining an SSL Certificate
First, you will need to acquire an SSL certificate. We recommend reviewing our list of top SSL certificate providers for reliable options. Upon purchase, you will receive the essential components required for SSL configuration: the certificate file, the Certificate Authority (CA) bundle, and the private key. These elements are crucial for setting up SSL on your server.
Important Considerations:
Record Keeping: Maintaining records of your SSL certificate purchase is vital, including the provider’s name and your account’s email and password. This information is essential for managing your SSL certificate, including annual renewals and security updates.
Configuring SSL on Apache Web Server
To secure your website with SSL, follow these steps to configure your Apache server. This process involves editing your Apache configuration file, setting up a VirtualHost for HTTPS, and enabling the SSL module.
Step 1: Edit Apache Configuration File
Locate and edit your Apache configuration file for your website:
- Open the configuration file with a text editor (such as `nano` or `vim`):
sudo nano /etc/apache2/sites-available/yourdomain.conf
- Within this file, set up a `<VirtualHost>` block for port 443 to enable SSL. Ensure you include the SSL certificate details provided by your certificate authority. Here is an example configuration:
<VirtualHost *:443>
ServerName yourdomain.com
SSLEngine on
SSLCertificateFile /path/to/your_certificate.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/CA_bundle.crt
# Other directives and configurations specific to your site
</VirtualHost>
- Save and close the file.
Step 2: Enable SSL and Apply Configuration
Execute the following commands in your terminal to enable SSL, activate your site’s SSL configuration, and restart Apache to apply changes:
- Enable the SSL module:
sudo a2enmod ssl
This command activates the SSL module within Apache.
- Enable your SSL site configuration:
sudo a2ensite yourdomain.conf
This enables the new VirtualHost configuration you just edited.
- Restart Apache to apply the changes:
sudo systemctl restart apache2
This restarts the Apache server, applying all your changes.
You’ve successfully configured your Apache server to serve content over HTTPS by completing these steps, enhancing your website’s security.
How to install an Nginx web server SSL certificate
Securing your website with an SSL certificate on an Nginx server involves uploading your certificate files, configuring Nginx to use these files, and then ensuring the server uses these settings for secure connections. Follow these steps to complete the setup.
Step 1: Install the Certificate Files
First, upload the SSL certificate you’ve obtained to your server. This typically includes:
– The primary certificate file for your domain (e.g., `yourdomain.crt`)
– The private key file generated when you created the CSR (e.g., `yourdomain.key`)
– Optionally, the CA bundle (intermediate certificates) provided by your SSL issuer (e.g., `ca_bundle.crt`)
Configuring SSL Certificate on an Nginx Web Server
Step 2: Configure Nginx
- Open your Nginx configuration file for editing. This file is usually located in `/etc/nginx/sites-available/yourdomain`. Use a text editor like `nano` or `vim`:
sudo nano /etc/nginx/sites-available/yourdomain
- Modify the server block for your domain to include SSL configuration. Ensure it listens on port 443 and specifies the paths to your SSL certificate and private key files:
server {
listen 443 ssl;
server_name yourdomain.com www.yourdomain.com;
ssl_certificate /path/to/yourdomain.crt;
ssl_certificate_key /path/to/yourdomain.key;
# Recommended SSL settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128...';
# Other Nginx configurations for your site
}
- If you have a CA bundle file, include it using the `ssl_trusted_certificate` directive.
- Save and close the file.
Step 3: Test and Restart Nginx
- Test your Nginx configuration for syntax errors:
sudo nginx -t
Ensure no errors are reported before proceeding.
- Restart Nginx to apply the changes:
sudo systemctl restart nginx
This will reload Nginx with your new SSL configuration.
By completing these steps, you’ve successfully configured your Nginx server to use SSL, enhancing the security of your website by enabling HTTPS. Remember to regularly check your SSL certificate’s expiration date and renew it as necessary to maintain your site’s security.