Failed to obtain cert on custom installed nginx

My domain is: frpdb.ptsapi.top

I ran this command: sudo certbot --nginx -d frpdb.ptsapi.com

It produced this output:

Plugins selected: Authenticator nginx, Installer nginx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for frpdb.ptsapi.com
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Encountered exception during recovery:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 70, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1134, in perform
    self.restart()
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 919, in restart
    nginx_restart(self.conf('ctl'), self.nginx_conf)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1202, in nginx_restart
    raise errors.MisconfigurationError(
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 243, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1152, in cleanup
    self.restart()
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 919, in restart
    nginx_restart(self.conf('ctl'), self.nginx_conf)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1202, in nginx_restart
    raise errors.MisconfigurationError(
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''
nginx restart failed:
b''
b''

My web server is (include version): nginx-1.21.0

The operating system my web server runs on is (include version): Ubuntu 20.04 LTS kernel:5.4.0-72-generic

My hosting provider, if applicable, is:

I can login to a root shell on my machine : yes

I'm using a control panel to manage my site: no

The version of my client is: certbot 0.40.0

I'm trying to get TLS set up on my server. I'm using custom installed nginx(complied myself), and I got the output above after executing that command. Maybe the custom installation is the problem, but I don't know what to do.
So how can I solve this?

Hi @drHuangMHT, and welcome to the LE community forum :slight_smile:

Using --nginx with a custom install can be difficult.
I would try using --webroot -w /the/doc/root instead.

image

Yeah, well, I'd better just use nginx installed from package manager.... Thanks!

1 Like

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