How to install LAMP and secure Apache with Let's Encrypt

I followed the two guides and My site was up and running on my remote server, and I got php to connect to my mysql db without errors. Then I followed the second guide to enable ssl and https on my site. Everything worked well, and I installed the Let’s Encrypt certificate. The only thing that didn’t work was the last test: “Try reloading your website using https:// and notice your browser’s security indicator.”…

Unfortunately I can’t load my website at all any longer, not with http nor https. The only thing I get from the browser is: “This site can’t be reached took too long to respond.” and say “Assessment failed: Unable to connect to the server”.

I know that my LAMP worked without errors before I installed the Let’s Encrypt certificate and enabled ssl, but I don’t know where to search for errors. Anyone else having the same issue?

I’m using Ubuntu 20.04.3 LTS

$ sudo apache2ctl configtest
Syntax OK

In /etc/apache2/sites-enabled I’ve got the two following files:

spiked-le-ssl.conf -> /etc/apache2/sites-available/spiked-le-ssl.conf
spiked.conf -> ../sites-available/spiked.conf
$ cat spiked-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
$ cat spiked.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
Apache Full                ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Apache Full (v6)           ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)
$ sudo apachectl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)

There is something I did wrong, but I cannot see what it is…

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.


I didn’t find my question on the forum so I didn’t update. It looked like an FW error, and after a while I remembered that AWS Lightsail has it’s own firewall. It’s been a while since I configured the server. So I opend port 443 in that and turned off ufw, and that was it.

Thanks for your suggestions, but this time it was the firewall :)


I could suggest checking if the Apache service is up and running with the following command:

sudo systemctl status apache2

If this is not the case you can start it with:

sudo systemctl start apache2

Let me know how it goes! Regards, Bobby