How Run Certbot in PHP

I’m attempting to use Certbot to issue a certificate via PHP exec() and 'shell_exec()' function. Here’s what the exec call looks like:

exec("certbot --nginx -d"); (sudo or without sudo)
shell_exec('certbot --nginx -d'); (sudo or without sudo)

When I did that I got the following error back is null

How run command certbbot using php? any idea?

@zulkifliraihan Welcome to the community.

I used this:
exec($cmd.' 2>&1',$outArr,$rc);

$cmd is your certbot command. My php was running in sudo so did not need it again
$outArr is array of lines output from certbot. The 2>&1 captures stderr too
$rc is the return code of the exec

Check the /var/log/letsencrypt/ folder for logs of each certbot run

Update: Oh, I was not using --nginx but using certonly with --webroot with these extra options that might be needed when running this way. I used other options too but those do not affect operation - just personal choices.


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