从PHP的结果无法找到凭据执行AWS CLI命令 [英] Executing AWS CLI command from php results in Unable to locate credentials
本文介绍了从PHP的结果无法找到凭据执行AWS CLI命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从内部使用shell的exec PHP code运行AWS的S3 cp命令。以下是PHP code。
I am trying to run aws s3 cp command from within php code using shell exec. Following is the php code.
echo shell_exec("sudo aws s3 cp s3://<bucket>/somefolder/somefile s3://<bucket>/someotherfolder/somefile --region ap-southeast-1 --acl public-read");
该文件没有得到复制和回声的输出是以下
The file is not getting copied and The output from echo is the following
无法找到与......文件(S)剩余完成1份(S)凭证
"Unable to locate credentials Completed 1 part(s) with ... file(s) remaining"
注1:我已经设置使用AWS配置命令的凭据
注2:如果我直接从终端上运行相同的指令,它工作正常
你知道吗?
推荐答案
在AWS CLI设置在〜/ .aws /配置凭据和AWS PHP SDK寻找他们在〜/ .aws /凭据。
The AWS CLI sets credentials at ~/.aws/config, and the aws php sdk looks for them at ~/.aws/credentials.
所以:
cd ~/.aws
mv config credentials
解决什么,我觉得对我来说是同样的问题。
Solved what I think is the same problem for me.
这篇关于从PHP的结果无法找到凭据执行AWS CLI命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文