从PHP的结果无法找到凭据执行AWS CLI命令凭据、命令、结果、PHP

由网友(梦中你说宝就是你的唯一...)分享简介:我想从内部使用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 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.

阅读全文

相关推荐

最新文章