I am trying to use the PHP exec function to generate a certificate dynamically.
I ran this command: exec("certbot certonly --webroot -w /var/www/html/mysite/ -d mydomain.com 2>&1", $output);
It produced this error: Either run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.
So I tried the following instead: exec("certbot certonly --webroot -w /var/www/html/mysite -d mydomain.com --config-dir /var/www/html/sslconfig 2>&1", $output);
Where sslconfig is a writeable path.
It gives me the same output
My web server is: NGINX
The operating system my web server runs on is: Ubuntu 18.04
The error message sums up three paths with the word "and". So just setting --config-dir isn't enough. The other two paths also need to be directories writable by the user running certbot.
You could of course run ls -l on the parent directory to list the rights, so you can paste them here. Or add -d to the command to list a directory seperately.
For example, I'm not sure if 775 is sufficient. That depends on the user and group of the directories.