How to change nginx config path

Error while running nginx -c /etc/nginx/nginx.conf -t.

my nginx.conf is not in /etc/nginx/
how to change it

1 Like

The path can be controlled:

nginx:
  Nginx Web Server plugin

  --nginx-server-root NGINX_SERVER_ROOT
                        Nginx server root directory. (default: /etc/nginx)
  --nginx-ctl NGINX_CTL
                        Path to the 'nginx' binary, used for 'configtest' and
                        retrieving nginx version number. (default: nginx)

But my advice is, if you don’t have a standard-ish nginx installation (from your OS repo), it might be safer to stick to using certbot certonly and avoiding the nginx plugin.

For example, it might not interact gracefully with nginx installations managed by Bitnami or ServerPilot.

2 Likes
[root@cander ~]# certbot --nginx --nginx-server-root /usr/local/nginx/conf/ --nginx-ctl /usr/local/nginx/sbin/nginx 
Saving debug log to /var/log/letsencrypt/letsencrypt.log
NGINX derivative hyahm.com
built by gcc 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC) 
built with OpenSSL 1.1.1d FIPS  10 Sep 2019
TLS SNI support enabled
configure arguments: --prefix= is not officially supported by certbot
An unexpected error occurred:
ValueError: invalid literal for int() with base 10: ''
Please see the logfiles in /var/log/letsencrypt for more details.
configure arguments: --prefix= is not officially supported by certbot
2020-01-09 18:17:59,449:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==1.0.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python3.7/site-packages/certbot/main.py", line 14, in main
    return internal_main.main(cli_args)
  File "/usr/lib/python3.7/site-packages/certbot/_internal/main.py", line 1350, in main
    return config.func(config, plugins)
  File "/usr/lib/python3.7/site-packages/certbot/_internal/main.py", line 1087, in run
    installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/selection.py", line 222, in choose_configurator_plugins
    authenticator = installer = pick_configurator(config, req_inst, plugins)
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/selection.py", line 24, in pick_configurator
    (interfaces.IAuthenticator, interfaces.IInstaller))
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/selection.py", line 105, in pick_plugin
    verified.prepare()
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/disco.py", line 252, in prepare
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/disco.py", line 252, in <listcomp>
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/usr/lib/python3.7/site-packages/certbot/_internal/plugins/disco.py", line 130, in prepare
    self._initialized.prepare()
  File "/usr/lib/python3.7/site-packages/certbot_nginx/_internal/configurator.py", line 194, in prepare
    self.version = self.get_version()
  File "/usr/lib/python3.7/site-packages/certbot_nginx/_internal/configurator.py", line 985, in get_version
    nginx_version = tuple([int(i) for i in product_version.split(".")])
  File "/usr/lib/python3.7/site-packages/certbot_nginx/_internal/configurator.py", line 985, in <listcomp>
    nginx_version = tuple([int(i) for i in product_version.split(".")])
ValueError: invalid literal for int() with base 10: ''
2020-01-09 18:17:59,451:ERROR:certbot._internal.log:An unexpected error occurred

Well, /usr/local/nginx is not likely to be the correct configuration root.

If it’s nginx make install'd from upstream on Linux, it would probably be /usr/local/nginx/conf. YMMV.

Edit: I see you figured that out on your own. You’re out of luck with the version parsing crash though. Either use standard nginx or use certonly like I suggested before.

2 Likes

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