Question

Installed LetsEncrypt to get SSL and now my website is not reachable

Posted July 18, 2020 394 views
ApacheWordPressDigitalOceanLet's Encrypt

I am following this tutorial https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-18-04 and after I followed the steps and went to my website it was gone. I tried to log into the WordPress admin panel and the webpage and got a 403 error. I realized I forgot to add domain.com (the .com part) so I repeated the steps. Now I get “Success! The your_domain virtual host is working!” when I go to domain.com, instead of my wordpress site I built. What happened to my website!?

I don’t know what to do help would be really appreciated.

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.

×
4 answers

Hi there @vinnyp96,

Can you share the content of your Apache virtual host? To do that you could first find the file with the following command

  • ls -lah /etc/apache2/sites-enabled

There you should see 2 files associated with your domain name, one for your SSL Vhost and one for the non-SSL Vhost.

Then use the cat command to display the content:

  • sudo cat /etc/apache2/sites-enabled/your-domain.conf

Feel free to share the output here.

Also please check your Apache error log with the following command:

  • sudo tail -100 /var/log/apache2/error.log

Regards,
Bobby

Hi @bobbyiliev I appreciate your help!

output to ls -lah /etc/apache2/sites-enabled:

xxx@xxx:~$ ls -lah /etc/apache2/sites-enabled
total 12K
drwxr-xr-x 2 www-data www-data 4.0K Jul 18 03:40 .
drwxrwxr-x 8 www-data www-data 4.0K Jul 19 20:52 ..
-rw-rw-r-- 1 www-data www-data  523 May 25 19:43 000-default.conf
lrwxrwxrwx 1 root     root       54 Jul 18 03:11 <DOMAIN_NAME_HERE>.com-le-ssl.conf -> /etc/apache2/sites-available/<DOMAIN_NAME_HERE>-le-ssl.conf
lrwxrwxrwx 1 root     root       41 Jul 18 03:40 <DOMAIN_NAME_HERE>.com.conf -> ../sites-available/<DOMAIN_NAME_HERE>.com.conf

output for sudo cat /etc/apache2/sites/enabled/your-domain.conf:
-there was no sites/ so went into sites-enabled/

root@XXX:/etc/apache2/sites-enabled# cat <DOMAIN_NAME_HERE>.com.conf 
<VirtualHost *:80>    
    ServerAdmin webmaster@localhost    
    ServerName <DOMAIN_NAME>.com    
    ServerAlias www.<DOMAIN_NAME>.com    
    DocumentRoot /var/www/<DOMAIN_NAME>.com    
    ErrorLog ${apache_log_dir}/error.log
    CustomLog ${apache_log_dir}/access.log combined
</VirtualHost>

error.log was empty.

Thanks!

  • Hi there @vinnyp96,

    The Apache virtual host for port 80 actually looks correct.

    Can you share the contents of the SSL Vhost as well?

    • sudo cat /etc/apache2/sites-enabled/your-domain.com-le-ssl.conf

    Regards,
    Bobby

Hi @bobbyiliev,

root@XXX:~# sudo cat /etc/apache2/sites-enabled/<DOMAIN>.com-le-ssl.conf 
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost    
    ServerName <DOMAIN>.com    
    ServerAlias www.<DOMAIN>.com    
    DocumentRoot /var/www/<DOMAIN>.com    
    ErrorLog ${APACHE_LOG_DIR}/error.log    
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/<DOMAIN>.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<DOMAIN>.com/privkey.pem
</VirtualHost>
</IfModule> 

Also to add on: going to www.<domain>.com I get:

Success! The your_domain virtual host is working!

Going to http://<IP>/wp-admin/ I used to be able to login to Wordpress and edit my site, now I get:

Not Found

The requested URL was not found on this server.

Apache/2.4.29 (Ubuntu) Server at <DOMAIN>.com Port 443
  • Hi there @vinnyp96,

    Actually both the SSL and the non-SSL Vhosts look all correct. With a small exception, I would recommend adding the following to both your SSL and non-SSL virtual hosts:

    <Directory /var/www/yourdomain.com/>
        AllowOverride All
    </Directory>
    

    This would basically allow the usage of the .htaccess file which is needed by WordPress.

    After the change, run a config test:

    • sudo apachectl -t

    And if you get a Syntax OK message, restart Apache:

    systemctl restart apache2
    

    If you are still seeing the problem, I could suggest a couple of things:

    • Make sure that the file permissions for the /var/www/yourdomain.com folder are set correctly so that Apache could read and write accordingly. You can take a look at this article here on how to set that up:

    https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04

    • Check the content of the /var/www/yourdomain.com folder and make sure that it actually holds the files of your WordPress website:
    • ls -lah /var/www/yourdomain.com
    • Also share the content of the 000-default.conf file just to make sure that there are no problems coming from there

    Regards,
    Bobby

    by Brian Boucheron
    WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MySQL backend with PHP processing. In this guide, we'll focus on getting a WordPress instance set up on a LAMP stack (Linux, Apache, MySQL, and PHP) on an Ubuntu 18.04 server.
    • Hi @bobbyiliev,

      I added the

      <Directory /var/www/yourdomain.com/>
          AllowOverride All
      </Directory>
      

      and ran sudo apachectl -t. I got the output:

      # sudo apachectl -t
      
      [Wed Jul 22 03:23:16.783007 2020] [core:warn] [pid 3099] AH00111: Config variable ${apache_log_dir} is not defined
      [Wed Jul 22 03:23:16.783197 2020] [core:warn] [pid 3099] AH00111: Config variable ${apache_log_dir} is not defined
      AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
      (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/${apache_log_dir}/' for error log of vhost defined at /etc/apache2/sites-enabled/<DOMAIN>.com.conf:1
      AH00014: Configuration check failed
      Action '-t' failed.
      The Apache error log may have more information.
      

      Inside /var/www/yourdomain.com:

      root@xxx:/var/www/<DOMAIN>.com# cat index.html 
      <html>
          <head> 
              <title>Welcome to Your_domain!</title>    
          </head>    
          <body>        
              <h1>Success!  The your_domain virtual host is working!</h1>    
          </body>
      </html>
      

      I made this as part of the original tutorial when I started this SSL tutorial. This is definitely not my wordpress site, I don’t know where on this droplet that would be located…

      content of the 000-default.conf:

      
      root@xxx:/etc/apache2/sites-enabled# cat 000-default.conf 
      # Added to mitigate CVE-2017-8295 vulnerability
      UseCanonicalName On
      
      <VirtualHost *:80>
              ServerAdmin webmaster@localhost
      
              ServerName <DOMAIN>
              ServerAlias www.<DOMAIN>
      
              DocumentRoot /var/www/html
      
              <Directory /var/www/html/>
                  Options FollowSymLinks
                  AllowOverride All
                  Require all granted
              </Directory>
      
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
      root@xxx:/etc/apache2/sites-enabled# cd ..
      root@xxx:/etc/apache2# cd sites-available/
      root@xxx:/etc/apache2/sites-available# cat 000-default.conf
      # Added to mitigate CVE-2017-8295 vulnerability
      UseCanonicalName On
      
      <VirtualHost *:80>
              ServerAdmin webmaster@localhost
      
              ServerName $domain
              ServerAlias www.$domain
      
              DocumentRoot /var/www/html
      
              <Directory /var/www/html/>
                  Options FollowSymLinks
                  AllowOverride All
                  Require all granted
              </Directory>
      
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
      root@xxx:/etc/apache2/sites-available# 
      
      edited by bobbyiliev
      • Hi there @vinnyp96,

        What I could suggest is to disable the Vhosts that you do not need and leave only the one that you need with the correct DocumentRoot path to your WordPress files.

        At the moment in your /var/www/<DOMAIN>.com directory, you just have a default inedx.html file rather than your actual WordPress installation.

        Let me know how it goes.
        Regards,
        Bobby

To add one going to www.domain.com all I see is
“Success! The your_domain virtual host is working!”

Before I tried adding SSL and did all these steps, going to http://IP-address/wp-admin/ resulted in a WordPress login page and then I could edit my website. Now I get:

Not Found

The requested URL was not found on this server.

Apache/2.4.29 (Ubuntu) Server at <DOMAIN>.com Port 443
Submit an Answer