在php中检查apachectl configtest
我想在PHP中检查apachectl configtest的内容,但是下面的代码返回了一个错误,但是通过命令行运行它表示可以 此代码:在php中检查apachectl configtest,php,apache,Php,Apache,我想在PHP中检查apachectl configtest的内容,但是下面的代码返回了一个错误,但是通过命令行运行它表示可以 此代码: $output = shell_exec('/usr/sbin/apachectl configtest'); echo $output; 请给出: Action 'configtest' failed. The Apache error log may have more information. Syntax OK 但是像这样直接运行它: user@s
$output = shell_exec('/usr/sbin/apachectl configtest');
echo $output;
请给出:
Action 'configtest' failed.
The Apache error log may have more information.
Syntax OK
但是像这样直接运行它:
user@server:~# /usr/sbin/apachectl configtest
请给出:
Action 'configtest' failed.
The Apache error log may have more information.
Syntax OK
知道为什么吗
谢谢
更新:我检查了错误,它显示:
AH00526: Syntax error on line 17 of /etc/apache2/sites-enabled/000-default-le-ssl.conf:
SSLCertificateFile: file '/etc/letsencrypt/live/server/fullchain.pem' does not exist or is empty
但该文件确实存在(好吧,它是一个符号链接),并且该命令通过命令行工作。啊,我的错,我试图从外部访问它,但它不起作用,但当我通过命令行脚本将其作为php运行时,它确实起了作用,所以这并不重要。离开这里可能会有帮助。这可能是因为执行PHP的用户没有访问证书文件的权限,但命令行中的用户有。在类似的设置中,我在运行
[apache]configtest
时遇到错误,但在运行sudo[apache]configtest
(与超级用户运行相同的命令)时没有遇到错误,因为超级用户可以看到证书。apache日志是否提供了更多信息?