Certbot --apache fails

I ran this command: certbot --apache

It produced this output:

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

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

The line 32:

WSGIDaemonProcess lotto python-path=/var/www/django-apps/myap python-home=/var/www/django-apps/venv

Running apche2ctl configtest, passes without error.

My web server is (include version): Apache2 v2.4.52

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

My hosting provider, if applicable, is: AWS EC2

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): v1.31.0

It's probably this bug. There's a clever workaround using Define in one of the comments.

6 Likes

Wrapping it with Define fixed the error, and HTTPS is working fine. But I don't want to forward HTTP to HTTPS, so I removed:

#RewriteEngine on
#RewriteCond %{SERVER_NAME} =mydomain.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

And due to the wrapping with Define, HTTP defaults to ubuntu's initial default page. So after, removing the wrap, back to the original 000-default.conf, the apache won't start.

Nov 08 17:29:22 ip-172-31-35-63 systemd[1]: Starting The Apache HTTP Server...
Nov 08 17:29:22 ip-172-31-35-63 apachectl[16221]: AH00526: Syntax error on line 33 of /etc/apache2/sites-enabled/000-default.conf:
Nov 08 17:29:22 ip-172-31-35-63 apachectl[16221]: Name duplicates previous WSGI daemon definition.
Nov 08 17:29:22 ip-172-31-35-63 apachectl[16218]: Action 'start' failed.
Nov 08 17:29:22 ip-172-31-35-63 apachectl[16218]: The Apache error log may have more information.
Nov 08 17:29:22 ip-172-31-35-63 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Nov 08 17:29:22 ip-172-31-35-63 systemd[1]: apache2.service: Failed with result 'exit-code'.
Nov 08 17:29:22 ip-172-31-35-63 systemd[1]: Failed to start The Apache HTTP Server.

And the syntax error is on that same line as the original:

`WSGIDaemonProcess ......"

I had to remove that line from 000-default-le-ssl.conf, and now both HTTP and HTTPS comes up.

2 Likes