[英]Execute shell commands with PHP
我试图使用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:
看看php exec()中的sudo或google中的“ php sudoers”。
您的脚本以apache用户身份运行,没有root权限。 因此,您需要在/ etc / sudoers中创建一个条目(或在sudoers.d中放置一个文件),以便能够以root用户身份从脚本运行certbot-auto。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.