0

I am trying to execute this command using the shell_exec function from PHP:

shell_exec("cd /home/ec2-user; ./certbot-auto -n --apache -d mydomain.com");

When i execute direct from terminal the result is this:

Requesting to rerun ./certbot-auto with root privileges...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mydomain.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/httpd/conf.d/vhost-le-ssl.conf
Deploying Certificate to VirtualHost /etc/httpd/conf.d/vhost-le-ssl.conf

But when i execute in my app, my result is only the first line:

Requesting to rerun ./certbot-auto with root privileges...

How can i fix this?

Obs:

  • I am trying to install Certbot SSL certificates.
  • My app is in Amazon AWS
  • I do not have much knowledge on servers.
  • I am using Laravel 5.5 in my app.
Inove Commerce
  • 65
  • 1
  • 1
  • 10

1 Answers1

0

Take a look at sudo in php exec() or google for "php sudoers".

Your script is running as apache user and hasn't rights as root; so you need to make an entry in /etc/sudoers (or put a file in sudoers.d) to be able to run certbot-auto as root from your script.

insad
  • 66
  • 2