我正在尝试使用PHP的shell_exec函数执行此命令:
shell_exec("cd /home/ec2-user; ./certbot-auto -n --apache -d mydomain.com");
当我从终端直接执行时,结果如下:
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
但是当我在我的应用程序中执行时,我的结果只是第一行:
Requesting to rerun ./certbot-auto with root privileges...
我该如何解决这个问题?
Obs:
答案 0 :(得分:0)
查看sudo in php exec()或google for" php sudoers"。
您的脚本以apache用户身份运行,并且没有root权限;所以你需要在/ etc / sudoers中创建一个条目(或者在sudoers.d中放一个文件)才能从你的脚本中以root身份运行certbot-auto。