GoAdmio

checkapache

Test the Apache configuration and remove SSL virtual hosts whose Let's Encrypt certificate is missing, then rebuild the configuration

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

Apache refuses to start or reload when a virtual host points to an SSL certificate file that does not exist. /go/checkapache repairs this situation. It:

It works only on servers that run Apache. On an Nginx server it does nothing; use checknginx there.


Quick start

/go/checkapache

Syntax

/go/checkapache

The command takes no options or arguments. Run it as root.


Options

None. Any arguments you pass are ignored.


Output

The command prints one line for each virtual host it removes:

Deleting example.com Configuration

It prints nothing when the test finds no matching error, or when the server runs Nginx. The result of the Apache test itself is not shown. It is saved in /usr/local/goadmio/tmp/checkapache.db.

Each run also adds a line to /var/log/go/checkapache.log.


Examples

# Check and repair
/go/checkapache
# Read the result of the Apache test that the command saved
cat /usr/local/goadmio/tmp/checkapache.db
# Confirm that Apache is healthy afterwards
apachectl configtest
# Install a new certificate for a domain whose configuration was removed
/go/ssl example.com

Troubleshooting

Symptom Likely cause Fix
Nothing is printed, but Apache still fails The error does not mention a Let's Encrypt certificate path, or the domain has no /home/<domain>/www folder. Run apachectl configtest and fix the error shown.
Nothing is printed on an Nginx server The command only works with Apache. Use checknginx.
A domain has no HTTPS after the command Its SSL virtual host was deleted because the certificate was missing. Install a certificate again with ssl or installssl.
The same domain is removed every time The certificate keeps going missing, for example because renewal fails. Check the domain's DNS and renew the certificate with ssl.
The test file cannot be written The command was run without root. Run it as root.

Details

What it does, in order

  1. Logs the run to /var/log/go/checkapache.log.
  2. Reads the web server name from /usr/local/goadmio/linux/ws.db. If it is not Apache, the command stops here.
  3. Runs apachectl configtest and saves its output to /usr/local/goadmio/tmp/checkapache.db.
  4. Extracts every name that follows /live/ in that output, which is the domain folder inside the Let's Encrypt certificate path, and saves the list in /usr/local/goadmio/tmp/apache.db.
  5. For each name in the list that is a hosted domain (/home/<domain>/www exists), prints Deleting <domain> Configuration and deletes its file <domain>-le-ssl.conf from the Apache virtual host folder. Both the /etc/httpd/vbost/ and the /etc/apache2/vbost/ locations are cleaned.
  6. If anything was deleted, rebuilds the configuration with conf.

Which errors it handles

Only errors whose text contains a Let's Encrypt path such as /etc/letsencrypt/live/example.com/... are handled, typically a certificate or key file that does not exist or is empty. Other configuration errors are saved in the test file but are not fixed.

Known issues


See also

Command Description
checknginx Validate the Nginx configuration and remove vhosts with no site directory
conf Rebuild the Apache/Nginx configuration in GoAdmio
apache Convert a GoAdmio server from Nginx to Apache
ssl Install an SSL certificate for a domain in GoAdmio
checkssl Check if SSL certificates are installed for all domains
reload Reload PHP-FPM and the active web server