letsencrypt Apache vhost

letsencrypt Apache vhost config on Ubuntu

Solving letsencrypt Apache vhost config issues

Setting up letsencrypt can be tricky with different variations of apache vhost configs. Here is how to set up letsencrypt Apache vhost config correctly:

(Note: letsencrypt is now certbot. The environment I am using is apache2 by DigitalOcean for Ubuntu/Wordpress VPS, single domain name)

During the interactive set-up of letsencrypt, I was greeted with

After checking the apache2.conf , I found that there is actually only one vhost in the file:

So why was there an error? I know it’s time to dig out apache documentations. After searching around I found that typically the vhost information is not included in  apache2.conf but rather in a separate .conf file. So I followed How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS to properly set up the vhost.
First I copied default template into a new file:

Then inside the new file, cut and paste the vhost information from the  apache2.conf. I also did some modifications to the vhost by following the standard. The result is a bit different from the default one above I got from the DigitalOcean:

Finally, I have my .conf correctly generated inside /etc/apache2/sites-enabled by issuing

After that, the letsencrypt client is finally happy and everything worked.

Update: Now the official client for letsencrypt is renamed as certbot, released by eff, hopefully it has resolved this issue by now.

One comment

Leave a Reply