Tutorial

How To Secure Apache with Let's Encrypt on Ubuntu 14.04

How To Secure Apache with Let's Encrypt on Ubuntu 14.04
Not using Ubuntu 14.04?Choose a different version or distribution.
Ubuntu 14.04

###Introduction

This tutorial will show you how to set up a TLS/SSL certificate from Let’s Encrypt on an Ubuntu 14.04 server running Apache as a web server.

SSL certificates are used within web servers to encrypt the traffic between the server and client, providing extra security for users accessing your application. Let’s Encrypt provides an easy way to obtain and install trusted certificates for free.

##Prerequisites

In order to complete this guide, you will need:

When you are ready to move on, log into your server using your sudo-enabled account.

##Step 1 — Download the Let’s Encrypt Client

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the certbot software on your server. The Certbot developers maintain their own Ubuntu software repository with up-to-date versions of the software. Because Certbot is in such active development it’s worth using this repository to install a newer Certbot than provided by Ubuntu.

First, add the repository:

  1. sudo add-apt-repository ppa:certbot/certbot

You’ll need to press ENTER to accept. Afterwards, update the package list to pick up the new repository’s package information:

  1. sudo apt-get update

And finally, install Certbot from the new repository with apt-get:

  1. sudo apt-get install python-certbot-apache

The certbot Let’s Encrypt client is now ready to use.

##Step 2 — Set Up the SSL Certificate

Generating the SSL Certificate for Apache using the certbot Let’s Encrypt client is quite straightforward. The client will automatically obtain and install a new SSL certificate that is valid for the domains provided as parameters.

To execute the interactive installation and obtain a certificate that covers only a single domain, run the certbot command with:

  1. sudo certbot --apache -d example.com

If you want to install a single certificate that is valid for multiple domains or subdomains, you can pass them as additional parameters to the command. The first domain name in the list of parameters will be the base domain used by Let’s Encrypt to create the certificate, and for that reason we recommend that you pass the bare top-level domain name as first in the list, followed by any additional subdomains or aliases:

  1. sudo certbot --apache -d example.com -d www.example.com

For this example, the base domain will be example.com.

You will be prompted to provide an email address for lost key recovery and notices, and you will be need to agree to the Let’s Encrypt terms of service. You’ll then be asked to choose between enabling both http and https access or force all requests to redirect to https.

When the installation is finished, you should be able to find the generated certificate files at /etc/letsencrypt/live. You can verify the status of your SSL certificate with the following link (don’t forget to replace example.com with your base domain):

https://www.ssllabs.com/ssltest/analyze.html?d=example.com&latest

You should now be able to access your website using a https prefix.

Step 3 — Verifying Certbot Auto-Renewal

Let’s Encrypt certificates only last for 90 days. However, the certbot package we installed takes care of this for us by running certbot renew twice a day via a systemd timer. On non-systemd distributions this functionality is provided by a cron script placed in /etc/cron.d. The task runs twice daily and will renew any certificate that’s within thirty days of expiration.

To test the renewal process, you can do a dry run with certbot:

  1. sudo certbot renew --dry-run

If you see no errors, you’re all set. When necessary, Certbot will renew your certificates and reload Apache to pick up the changes. If the automated renewal process ever fails, Let’s Encrypt will send a message to the email you specified, warning you when your certificate is about to expire.

##Conclusion

In this guide, we saw how to install a free SSL certificate from Let’s Encrypt in order to secure a website hosted with Apache. We recommend that you check the official Let’s Encrypt blog for important updates from time to time, and read the Certbot documentation for more details about the Certbot client.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar

Developer Advocate

Dev/Ops passionate about open source, PHP, and Linux.


Default avatar

Developer Advocate

Dev/Ops passionate about open source, PHP, and Linux.


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
60 Comments
Leave a comment...

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!

I had had problem in ubuntu 14.04 server with python. So i add ppa for never python version (it is bad idea lol) Also if you have TLS cert it is good idea to enable HTTP/2 in your server too.

I’ve been unable to successfully install this cert. Every time I try to install it, I’m thrown to a screen stating “We were unable to find a vhost with a ServerName or Address of mydomain.com
Which virtual host would you like to choose?”

No matter which option I choose, I’m then faced with the following error message. “Error while running apache2ctl configtest. Action ‘configtest’ failed. The Apache error log may have more information. AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/000-default.conf.save-le-ssl.conf: ServerName takes one argument, The hostname and port of the server”

Any idea how I can get this working?

Hi @danK010 ! It seems like Let’s Encrypt is unable to find your domain in the default website configuration file. Do you have the ServerName directive set up with this domain name?

I had the same problem for me the solution was first to have a separate vhost file on etc/apache2/sites-available for each website/domain (previously had all the virtual hosts on 000-default.conf) and second, very important at least on Debian 8 and Apache 2.4, each vhost file should end in .conf

Also in your: sites-available/what-ever-your-vh-file-is-called.conf

Add this to the bottom of the file (of course changing EXAMPLE.COM to the directory where letsencrypt put your certs)

<VirtualHost *:443>

    ...

    SSLEngine ON
    SSLCertificateFile /etc/letsencrypt/live/EXAMPLE.COM/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/EXAMPLE.COM/privkey.pem
</VirtualHost>

Hi Erika, what about installing on centos?

i think i should go with the Docker method!

Great Article.I just set up for my domain. Just set up the virtual host as per https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts if you are getting the default.conf tab.

Hi @erikaheidi, thanks for this article and renewal script! I recently made a blog post describing how to set it up with nginx, in this post I’ve added a link to this post, and a link to an edited le-renew script which I’ve made to run with nginx, based on the script you provide in this post. I hope you don’t mind :)

The blog post can be read here

Solved

"I tried following these instructions but seem to get an error that says

"IMPORTANT NOTES:

  • The following ‘urn:acme:error:connection’ errors were reported by the server:

    Domains: mydomain.com Error: The server could not connect to the client to verify the domain"

I had to unblock port 443 in ufw

Thanks for the tutorial.

Thanks, this helped me out!

How did you unblock the port 443? I’m having the same problem.

I looked over the internet for a way to open this port, but I didn’t find nothing that solved my problem.

Thank you for the help!

Hej there, I am always getting the following error when hitting ./letsencrypt-auto --apache --d iamjannik.me:

Updating letsencrypt and virtual environment dependencies.../root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
./root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
./root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Failed building wheel for cryptography
  Failed building wheel for cffi
Command "/root/.local/share/letsencrypt/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-H1F6og/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NfyK5J-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.local/share/letsencrypt/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-H1F6og/cffi

Maybe, one of you can help me… :/

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
December 28, 2015

It looks like python-cffi and python-cryptography are failing to install. Try running sudo apt-get install libffi-dev first if it isn’t already installed.

Is there a away for Apache to force visitors to use HTTPS only. I had the option selected but I can still browse my site on http://www.mysite.com - https://www.mysite.com does also work.

It’s been a while, but here are two options for the /etc/apache2/sites-enabled/xxx.conf files

  1. Rewrite all requests to HTTPS (this is what Let’s Encrypt uses, I think)
RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
  1. Only redirect / (this was my method, since it’s easier to read. But I think that it’ll only redirect example.com, to https://example.com, not example.com/foo/bar.)
<VirtualHost *:80>
  ServerName mail.nitkin.net
  ServerAlias mail.nitk.in
  Redirect "/" "https://mail.nitkin.net/"
</VirtualHost>

Thanks for the tutorial. Very helpful.

Seems the default version of python supplied with Ubuntu 14.04 may need some extra updates to run letsencrypt. I needed to update python’s ssl libraries:

apt-get install python-dev libffi-dev libssl-dev
apt-get install python-pip
pip install 'requests[security]'
pip install pyopenssl ndg-httpsclient pyasn1

Then I needed to import ssl into python.

python
import ssl
quit()

Also, I found my domain name example.com must have an A record on the DNS server and it must be the same IP address as the A record for www.example.com A CNAME DNS record for www.example.com is not sufficient – it must be an A record.

Thanks for the article. Although the script will generate an error if you have multiple vhosts, it does generate the certificate even though it does not update the apache configuration. This is easily fixed by manually adding the statements to the vhost file for each site and restarting apache.

le-renew script depends on bc (not installed on Debian 8.2 Jessie). You need to apt-get install bc before running the script. Otherwise it seems to renew the certificate even if it’s not expired.

Ahh that might be my problem…I’ll try that.

Is it possible to modify the let’s encrypt script to cover all name virtual host you might have on a Apache instance? I host about 10 sites on one moderate sized server.

Hi, i tried this on CentOS, but i can’t get past the ./letsencrypt-auto part. It just tells me that phyton 2.6 is experimental, and then ends. If i use the --debug flag, it ends with “Too many flags setting configurators/installers/authenticators ‘webroot’ -> ‘apache’”

some help please?

Well, i’ve solved this upgrading to python 2.7, rebooting and reinstalling letsencrypt.

I used the following guide, steps 3 (installation) and 6 (automatic renewal). The only downside is that the guide is in spanish, but if you use google translate you might understand enough. It’s not difficult at all!

Good to know, well you can also access the english version of the article here

This is legit! I got it to work after some mucking around.

echo “alias python=python3” >> ~/.bashrc

&

removing my https > http redirect in .htaccess cuz mailinabox forwarded traffic https

now to legitimize mailinabox cert as well,

ty!

Just a heads up you need to have apache 2.4

This method will not work with apache 2.2 and less

If you’re hosting multiple domains (e.g. example.com and test.com) on the same VPS, here is the tutorial to follow: How to Set Up Let’s Encrypt for Multiple Apache Virtual Hosts.

Has anyone else tried to follow this tutorial on a DO instance that was setup with a free serverpilot account? Any luck? I tried… and… total disaster so far.

Edit: Ah. I should have read this article first:

How to set up a LetsEncrypt SSL Certificate for your WordPress Website on a Digital Ocean Server managed with a Serverpilot Free account

In case it helps, ServerPilot now has an integration with Let’s Encrypt on the paid accounts.

https://serverpilot.io/blog/2016/03/09/free-ssl-certificates-from-lets-encrypt.html

I get this error

Requesting root privileges to run letsencrypt… sudo /home/mohamed/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade --apache -d adove Requested domain is not a FQDN

Errors with the auto renew script - I get this, on a domain I was pretty sure that was already renewed? It’s possible it wasn’t since LE had domain issues yesterday, but pretty sure I did.

But the script is kicking out these errors even if you try one domain or two with le-renew. They were both subdomains though?

It also seemed to downgrade letsencrypt-auto, rather than upgrade?

sudo le-renew sub.domain.com /usr/local/sbin/le-renew: line 46: bc: command not found Checking expiration date for sub.domain.com… /usr/local/sbin/le-renew: line 50: [: : integer expression expected The certificate for sub.domain.com is about to expire soon. Starting renewal request… Checking for new version… Upgrading letsencrypt-auto 0.4.0.dev0 to 0.3.0… Replacing letsencrypt-auto… cp /tmp/tmp.i1TNmYlbW2/letsencrypt-auto /opt/letsencrypt/letsencrypt-auto Requesting root privileges to run letsencrypt… /home/tim/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade certonly --apache --renew-by-default --domains None Requested domain is not a FQDN Restarting Apache… * Renewal process finished for domain sub.domain.com

We stack on installing on muliti domains.

Does this work on a droplet thats connected to serverpilot and already has multiple websites? Can I make all the current active websites SSH with this?

I have a problem setting up Let’s Encrypt. After installation for some reason, when i add https before the domain, it gives me “ERR_CONNECTION_REFUSED”.

I use Apache, some one who has some ideas?

keep wathcing.

I tried this but got the following error. I need to mention that i have an active openvpn install on the same server that i use for my web server.

x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 4


Cleaning up… Command /home/shan/.local/share/letsencrypt/bin/python -c “import setuptools, tokenize;file=‘/tmp/pip-BzMb83-build/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’ ', ’ '), file, ‘exec’))” install --record /tmp/pip-O85kcr-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/shan/.local/share/letsencrypt/include/site/python2.7 failed with error code 1 in /tmp/pip-BzMb83-build Storing debug log for failure in /home/shan/.pip/pip.log

The solution could be to create a swapfile (for me python installation of cryptography was failing). And this is what worked:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288 sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile

https://github.com/certbot/certbot/issues/2324

Thanks for the article! I didn’t have any issues in setting this up. I think my experience was good because I setup my Virtual Hosts using the proper tutorial here on Digital Ocean Community.

My problem now is that my website is a little messed up. It’s a WordPress site on Ubuntu 14.04 LAMP, and was installed and setup before the SSL Certificate installation. Now, I am getting a ton of Mixed Content errors, in that although the pages are served over HTTPS, some of the content is being served over HTTP still. So, my question is…how to go back and make sure all my content and/or files are served over HTTPS? Would love some good answers here.

I am getting the following error after executing ./letsencrypt-auto --apache -d example.com and I have replaced example.com with my domain name.

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o

virtual memory exhausted: Cannot allocate memory

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1


Cleaning up… Command /home/ubuntu/.local/share/letsencrypt/bin/python -c “import setuptools, tokenize;file=‘/tmp/pip-goIQic-build/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’ ', ’ '), file, ‘exec’))” install --record /tmp/pip-58iMPy-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/.local/share/letsencrypt/include/site/python2.7 failed with error code 1 in /tmp/pip-goIQic-build

Hello Erika,

I just installed it following the exact instruction. My site broke, Here is[wordetail] what my site looks like

Hi all.

my problem is this: when i try to use the secure method (make all resquest redirect to secure https access), send me this message

“Unable to finalize checkpoint - adding title” “Unable to add title”

Only i need was use the redirect option from apache.

https://wiki.apache.org/httpd/RedirectSSL

make changes in

sudo nano /etc/apache2/sites-available/000-default-le-ssl.conf sudo nano /etc/apache2/sites-available/default-ssl.conf sudo nano /etc/apache2/sites-available/000-default.conf

Wonderful guide Erika! It works like a charm :)

can i use my droplets ip address instead of domain name? do i need to create the virtual host anyway?

Excellent Write up! Thank you

hi, although i haven’t find time to try it, thanks for this great tutorial. one think I should like to ask is that whether it is possible to add more subdomains later or not.

for example, I begin with example.com and www.example.com and then after a while I want to add newsubdomain.example.com.

Is it possible?

Thanks.

I use cloudflare for most of my sites, I need to renew via --webroot since I need to disable cloudflare every time I want to renew my cert, can someone provide a cron script for renew cert by webroot method? that would be helpful for others too :)

Received the following error: “failed to connect to host for DVSNI challenge”

After a quick google search I found out I needed to stop the apache service first before Step 3 would finish properly. Worked fine after that.

As another option, this script can handle the complete configuration for one domain. It would be easy to modify for multiple domains, but I haven’t gotten around to that yet. It follows this tutorial, but does it in an automated way, including setting up auto-renewal.

letsEncryptSetup.sh

I am having this \Error on using my domain anyone can help me? Failed authorization procedure. streamupbox.com (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: DNS problem: SERVFAIL looking up A for streamupbox.com

IMPORTANT NOTES:

  • The following errors were reported by the server:

    Domain: streamupbox.com Type: connection Detail: DNS problem: SERVFAIL looking up A for streamupbox.com

    To fix these errors, please make sure that your domain name was entered correctly and the DNS A record(s) for that domain contain(s) the right IP address. Additionally, please check that your computer has a publicly routable IP address and that no firewalls are preventing the server from communicating with the client. If you’re using the webroot plugin, you should also verify that you are serving files from the webroot path you provided.

Is your site publicly accessible at that domain? I’d double check to make sure you don’t have something in your hosts file or something.

I often develop new sites at dev.domain.com, and then put the new server’s ip in my hosts file with domain.com so I can develop easier. However, the LE servers won’t see it at domain.com.

That’s the first place I’d check.

btw, I am seeing your domain at 104.236.28.68. Is that what you see, or is it elsewhere?

I am always having this error ./letsencrypt-auto --apache -d streamupbox.com Checking for new version… Requesting root privileges to run letsencrypt… sudo /home/admin/.local/share/letsencrypt/bin/letsencrypt --apache -d streamupbox.com Failed authorization procedure. streamupbox.com (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: DNS problem: SERVFAIL looking up A for streamupbox.com

IMPORTANT NOTES:

  • The following errors were reported by the server:

    Domain: streamupbox.com Type: connection Detail: DNS problem: SERVFAIL looking up A for streamupbox.com

    To fix these errors, please make sure that your domain name was entered correctly and the DNS A record(s) for that domain contain(s) the right IP address. Additionally, please check that your computer has a publicly routable IP address and that no firewalls are preventing the server from communicating with the client. If you’re using the webroot plugin, you should also verify that you are serving files from the webroot path you provided.

Please can you help me?

This is my apache configuration <VirtualHost *:80>

    ServerName streamupbox.com
    ServerAlias www.streamupbox.com

    ServerAdmin info@streamupbox.com
    DocumentRoot /var/www/html/streamupbox/public

    <Directory /var/www/html/streamupbox/public>
    # Don't show directory index
    Options -Indexes +FollowSymLinks +MultiViews

    # Allow .htaccess files
    AllowOverride All

    # Allow web access to this directory
    Require all granted
</Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

</VirtualHost>

This comment has been deleted

    This comment has been deleted

      I followed the instructions given, but at the end of the process I always get this error:

      Error while running apache2ctl configtest. Action ‘configtest’ failed. The Apache error log may have more information.

      apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 20 of /etc/apache2/sites-enabled/dev-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>

      dev-le-ssl.conf doesn’t even exists in the sites-enabled folder… What am I doing wrong?

      Hi Erika, thank you so much for this article. I was able to issue my SSL certificate and everything ran smoothly. I justhad to try twice because I had to kill a process that was consuming a lot of memory but I was able to restart said process afterward. So, again, thank you very very very much!

      Me I follow the tutorial, all went fine but if I visit my website I’m in the loop of warning “cannot verify the identity…etc.” I click continue then the warning reapear!..a loop.

      I check the ssl, I get a grade A, restarted Apache…etc.

      Any Idea?

      Hi,

      I’m trying to get my certificate to work on specific ports but I don’t know how to do that. At the moment everything is working fine (thanks to this tutorial) when I’m going on my domain (https://mydomain.com).

      But when I try to use a specific port (for a node server for example) like the 8080, the certificate isn’t applied. (for example : https://mydomain.com:8080 isn’t working)

      is there a way to make it work ?

      Thank you!

      Very useful, thanks a lot.

      Thanks for the comprehensive instructions. I had to do a little extra work to configure my “.conf” file to get SSL working, but the Let’s Encrypt script did most of the work. The other tips, like setting up a cron job, are appreciated too… I’d never be disciplined enough to renew the license manually every 2 months.

      hi! thanks so much for the tutorial :)

      Unfortunately I get stuck at this command: /letsencrypt-auto --apache -d domain.com

      Ofcourse I replaced the domain.com with my own domain. I was only able to find some threads concerning zName, but my insufficient brain doesn’t allow me to understand it. I’m not sure how to proceed :/

      Failed authorization procedure. domain.com (tls-sni-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Correct zName not found for TLS SNI challenge. Found ‘’

      IMPORTANT NOTES:

      • The following errors were reported by the server:

        Domain: domain.com Type: unauthorized Detail: Correct zName not found for TLS SNI challenge. Found ‘’

        To fix these errors, please make sure that your domain name was entered correctly and the DNS A record(s) for that domain contain(s) the right IP address.

      Can anybody show me how to fix this error? Thank you!

      Ok this might not be a solution for you problem but I had exactly the same non descript error message when I made the school boy error of not opening port 443 on my firewall, the authentication is all done over HTTPS which is on a different port… if you’ve followed the default config guides and this is the first cert you’ve installed on that server, there’s a good change that’s what you’ve forgotten to do.

      spent at least an hour banging my head against a wall till I found someone else who’d done the same through google.

      Hi there,

      Does anyone know how to delete completely the certs for a single domain?

      I setup only for https but I have some requests in one of my sites that needs http simple and the site is crashed because of it.

      I tried to delete all the references to this domain in /etc/letsencrypt/archive /etc/letsencrypt/renewal and /etc/letsencrypt/live but my site is only under https and http isn’t allowed…

      I tried to execute again the letsencrypt script but choosing both “http” and “https” but it doesn’t work…

      May anyone help me, please?

      Thanks!

      Ok got it, I forgot to disable the site from /etc/apache2/sites-available

      Also, I had to remove some lines in my site.conf. Those lines were for redirect from http to https

      After that, reloaded or restarted Apache and it worked.

      I had this configured on my site, but unfortunately, https screws up all of my podcast feeds. How can I remove all of this? My site is currently down due to https.

      It’s worth noting that the procedure for auto-renewing the certs appears to have changed. According to the archived version of this tutorial, we needed to use a custom script.

      It seems the custom script not only is no longer needed, but will not correctly auto-update anymore?

      This comment has been deleted

        After sudo git pull: Is this something I should be worried about?

        error: Your local changes to the following files would be overwritten by merge: letsencrypt-auto Please, commit your changes or stash them before you can merge.

        Cheers, Anders

        Great Article Erika!

        I did have some trouble with getting Apache to work. The let’s encrypt client couldn’t figure out where my Virtual Host is located (because I hadn’t set it up BEFORE I ran letsencrypt). So, it gave me a choice and I selected /etc/apache2/sites-available/000-default.conf

        I tweaked the 000-default.conf file like so:

        <VirtualHost *:443>
        
                ...
        
                SSLEngine ON
                SSLCertificateFile /etc/letsencrypt/live/YOURDOMAIN.COM/cert.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/YOURDOMAIN.COM/privkey.pem
        </VirtualHost>
        

        Don’t forget to restart Apache :)

        This makes it so incredibly easy to install an SSL. Thank you!

        Problem:

        After running ./letsencrypt-auto --apache -d example.com I received an error:

        Traceback (most recent call last):
          File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2339, in <module>
            main()
          File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 825, in main
            symlink=options.symlink)
          File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 985, in create_environment
            site_packages=site_packages, clear=clear, symlink=symlink))
          File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1159, in install_python
            mkdir(lib_dir)
          File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 447, in mkdir
            os.makedirs(path)
          File "/usr/lib/python2.7/os.py", line 150, in makedirs
            makedirs(head, mode)
          File "/usr/lib/python2.7/os.py", line 150, in makedirs
            makedirs(head, mode)
          File "/usr/lib/python2.7/os.py", line 150, in makedirs
            makedirs(head, mode)
          File "/usr/lib/python2.7/os.py", line 150, in makedirs
            makedirs(head, mode)
          File "/usr/lib/python2.7/os.py", line 157, in makedirs
            mkdir(name, mode)
        OSError: [Errno 13] Permission denied: '/home/user/.local'
        

        Solution:

        Create the directory manually, chown to your user and chmod to 0700.

        $ sudo mkdir /home/user/.local
        $ sudo chown user:user /home/user/.local
        $ sudo chmod 0700 /home/user/.local
        

        Hope this helps others.

        I’m getting stuck on “Installing Python packages…”

        Anyone know why this could be happening?

        I needn’t to have a domain name, I have a rest api that is accessible through a mobile client. So, Can I still use the free “lets encrypt” certificates?

        The problem is if the certificate expires somewhere in between the week, we should have a check every day

        Good article. I tried implementing the same in AWS instance, but https is not working properly. Completed all the steps mentioned above except cron tab (which I dont want to experiment now) and did configured VH conf file with the SSL tags. I can see the site through http, but not with https (error:This site can’t be reached).

        BTW, I also got the below error, when tried to create certificate (cert not created):

        Domain: www.cloudpresence.in Type: connection Detail: Failed to connect to <ip>:443 for TLS-SNI-01 challenge

        To fix these errors, please make sure that your domain name was entered correctly and the DNS A record(s) for that domain contain(s) the right IP address. Additionally, please check that your computer has a publicly routable IP address and that no firewalls are preventing the server from communicating with the client. If you’re using the webroot plugin, you should also verify that you are serving files from the webroot path you provided.

        I am pretty sure that there’s a public IP for this server. Can you please help me on this? Thanks in advance.

        There seems to be an issue with CloudFlare blocking auto-renewal, related to a TLS check. I get something like this:

        WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/domain.com.conf produced an unexpected error: Failed authorization procedure. www.domain.com (tls-sni-01): urn:acme:error:tls :: The server experienced a TLS error during domain verification :: Failed to connect to 104.28.3.239:443 for TLS-SNI-01 challenge, domain.com (tls-sni-01): urn:acme:error:tls :: The server experienced a TLS error during domain verification :: Failed to connect to 104.28.3.239:443 for TLS-SNI-01 challenge. Skipping.
        

        I have to disable CloudFlare each time I want a certificate to renew, which isn’t great.

        Does anyone have a workaround?

        Try DigitalOcean for free

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

        Sign up

        Join the Tech Talk
        Success! Thank you! Please check your email for further details.

        Please complete your information!

        Become a contributor for community

        Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

        DigitalOcean Documentation

        Full documentation for every DigitalOcean product.

        Resources for startups and SMBs

        The Wave has everything you need to know about building a business, from raising funding to marketing your product.

        Get our newsletter

        Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

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

        The developer cloud

        Scale up as you grow — whether you're running one virtual machine or ten thousand.

        Get started for free

        Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

        *This promotional offer applies to new accounts only.