I am running this command opendkim-genkey --domain=example.com --selector=example --subdomains
on Linux terminal, It is working properly, but when I try to run this in my PHP page like shell_exec("opendkim-genkey --domain=example.com --selector=example --subdomains");
this is not working.. I also try to run another command in my php page, and I get result of them.
I can see three explanations:
opendkim-genkey
is not found because the environment variables are not the same: use an absolute path
Your Apache (or other webserver) user does not have permission to execute this command: you can use sudo, see https://serverfault.com/questions/157272/allow-apache-to-run-a-command-as-a-different-user
And as @rups suggested, your user may need write permission (if opendkim-genkey
generates a key file)