Question

How to set ssl certs to virtualhost digitalocean

I have set multidomain in the VPS DigitalOcean Ubuntu 20.04.

In the configuration of the secondary domain, I would like to set up an SSL security certificate and then do it on port 443. but if I set it in the conf it doesn’t work. What am I doing wrong?

I am attaching the configuration on ports 80 and 443:


PORT 80

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.tv
        ServerAlias www.example.tv
        DocumentRoot /var/www/example.tv/public_html
		
	<Directory /var/www/example.tv/public_html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
</VirtualHost>

PORT 443

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName example.tv
        ServerAlias www.example.tv
        DocumentRoot /var/www/example.tv/public_html
		
		SSLEngine on
		SSLCertificateFile /etc/ssl/example.crt
		SSLCertificateKeyFile /etc/ssl/private/example.key
		SSLCertificateChainFile /etc/ssl/example.ca-bundle

        <Directory /var/www/example.tv/public_html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
</VirtualHost>

The second set doesn’t function.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 14, 2022

Hi there,

The configuration looks correct. What is the exact error that you are getting?

I could suggest a few things:

  • Make sure to check your Apache error log:
tail -100 /var/log/apache2/error.log
  • Run an Apache config test with:
sudo apachectl -t

Feel free to share any of the errors here.

Also as a side note, I usually would suggest following the steps here on how to get a free SSL certificate using certbot which also automates the SSL installation and the virtual host configuration:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.