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

I've been stuck on this for awhile. Any help will be appreciated. :pray:

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: pulserank.info

I ran this command: sudo certbot install --cert-name pulserank.info

It produced this output: Saving debug log to /var/log/letsencrypt/letsencrypt.log
Deploying certificate
Successfully deployed certificate for pulserank.info to /etc/apache2/sites-available/FlaskApp-le-ssl.conf
Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

AH00526: Syntax error on line 4 of /etc/apache2/sites-enabled/FlaskApp.conf:
Name duplicates previous WSGI daemon definition.

We were unable to install your certificate, however, we successfully restored your server to its prior configuration.
Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

AH00526: Syntax error on line 4 of /etc/apache2/sites-enabled/FlaskApp.conf:
Name duplicates previous WSGI daemon definition.

My web server is (include version): Apache2: Server version: Apache/2.4.41 (Ubuntu)
Server built: 2023-03-08T17:32:54

The operating system my web server runs on is (include version): Ubuntu 20.04.6 LTS

My hosting provider, if applicable, is: Google Compute Engine

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): certbot 2.6.0

Some other commands I ran to try and debug myself and their outputs:

sudo tail -f /var/log/letsencrypt/letsencrypt.log
AH00526: Syntax error on line 4 of /etc/apache2/sites-enabled/FlaskApp.conf:
Name duplicates previous WSGI daemon definition.

2023-06-04 15:12:48,616:ERROR:certbot._internal.log:Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

AH00526: Syntax error on line 4 of /etc/apache2/sites-enabled/FlaskApp.conf:
Name duplicates previous WSGI daemon definition.

sudo tail -f /var/log/apache2/error.log
[Sun Jun 04 13:11:00.794391 2023] [core:error] [pid 30453] [client 83.97.73.89:57416] AH00126: Invalid URI in request POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh HTTP/1.1
[Sun Jun 04 14:55:31.452648 2023] [mpm_prefork:notice] [pid 27583] AH00171: Graceful restart requested, doing restart
[Sun Jun 04 14:55:32.586450 2023] [mpm_prefork:notice] [pid 27583] AH00163: Apache/2.4.41 (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Sun Jun 04 14:55:32.586492 2023] [core:notice] [pid 27583] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jun 04 14:58:23.343556 2023] [mpm_prefork:notice] [pid 27583] AH00171: Graceful restart requested, doing restart
[Sun Jun 04 14:58:24.086578 2023] [mpm_prefork:notice] [pid 27583] AH00163: Apache/2.4.41 (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Sun Jun 04 14:58:24.086617 2023] [core:notice] [pid 27583] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jun 04 15:12:48.600561 2023] [mpm_prefork:notice] [pid 27583] AH00171: Graceful restart requested, doing restart
[Sun Jun 04 15:12:49.089882 2023] [mpm_prefork:notice] [pid 27583] AH00163: Apache/2.4.41 (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Sun Jun 04 15:12:49.089923 2023] [core:notice] [pid 27583] AH00094: Command line: '/usr/sbin/apache2'

sudo apache2ctl configtest
Syntax OK

Here is my config file:
FlaskApp.conf:
<VirtualHost *:80>
ServerName pulserank.info
ServerAdmin admin@pulserank.info
WSGIDaemonProcess FlaskApp python-path=/var/www/FlaskApp:/var/www/FlaskApp/FlaskApp/venv/lib/python3.8/site-packages
WSGIProcessGroup FlaskApp
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all

Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all

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

See Certbot failing to install on apache / django sites, it looks like sort of the same issue with the fact that Certbot tries to copy the WSGI related directives from the HTTP virtualhost to the HTTPS virtualhost, but that would lead to duplicates.

The thread also mentions a solution.

3 Likes

This worked! Thank you for finding that other post!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.