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.

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