Failed to find apachectl (Centos6, whm, cpanel)

Hello,

I'm trying to install letsencrypt on a centos6 server.

My server has WHM installed, and I think paths are not usuals (I have admins to check the server, but they only install ssl if I pay $150).

My path to apachectl is:
/usr/local/apache/bin/apachectl

I have instaled certbot ok with:
sudo yum install epel-release
sudo mkdir /usr/local/letsencrypt
cd /usr/local/letsencrypt
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x certbot-auto

But when I run:

sudo ./certbot-auto --apache
or
sudo ./certbot-auto --apache certonly

I have this errors:


/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/init.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Failed to find apachectl in expanded PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
Could not choose appropriate plugin: The apache plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError('Cannot find Apache control command apachectl',)
The apache plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError('Cannot find Apache control command apachectl',)

I think the warning about phyton is not important (I'm not sure), and the problem is the path to apachectl.

I have tried to use:
export PATH=$PATH:/usr/local/apache/bin

to add apachectl to the path, but without any result 8(

ps. This is the same problem of this topic:

and there are only an answer: run "sudo yum install httpd mod_ssl" , but I have mod_ssl installed, I can see it running /usr/local/apache/bin/httpd -l , and I see mod_ssl.c

Thank you in advance

Hi @chok_dee,

I think the effect of the PATH setting is lost because sudo resets it entirely.

You can see this from

PATH=/whoops /usr/bin/sudo env

where the PATH is in fact reset to a default one, not inherited from your non-root shell.

You might be able to get it to find your apachectl with something like

sudo env PATH=$PATH:/usr/local/apache/bin ./certbot-auto --apache

or by running an interactive shell with sudo -s and then changing your PATH from within that shell before running certbot-auto.

2 Likes

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