简体   繁体   中英

AWS S3 work with a local project but on AWS EC2 doesn't with the same project (Codeigniter PHP)

This problem is driving me crazy, when I tested my codeigniter applicacion in local server everything was ok then I uploaded it in AWS EC2 (Ubuntu server) but when I try to upload a Image to AWS S3 from AWS EC2, I get a error 500. I use the library https://github.com/psugand/CodeIgniter-S3 , somebody have used aws s3 and aws ec2 with a codeigniter app, I need its advice.

the error appear when this code is run:

    $this->load->library('s3');
    $this->s3->putObject($this->s3->inputFile($file,false),
                         $Bucket,
                         $name,
                         self::ACL_PUBLIC_READ);

I think that codeigniter is not connecting with AWS S3.

Thank you

All this is happening due to permissions issues make sure that all the permissions must be 755 for the files in server for changing permission you must use

this is for the single file

chmod 755 ./name/of/file

and this is to change multiple files or all files in a folder

chmod 755 -R /folderlocation/andname

and if permission denied use sudo

What is the bucket policy you have currently set with S3? Are you using separate IAM accounts that may be conflicting from a local environment to your Cloud environment (access keys, permissions etc.)

If you're able to (very) temporarily remove security restrictions until you're able to have a successful connection you will be able to nail down exactly what's causing your errors. You can then throw on the levels of security you personally define and find the problem (I'd put a bet on Bucket Policies)

If you've launched into a VPC you may also have issues with your instances being internet-routable, is this a new environment within AWS?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM