๐Ÿš€ Languege/php

[aws phpsdk ์„ค์น˜]

mini_world 2021. 11. 19. 17:59
๋ชฉ์ฐจ ์ ‘๊ธฐ

 

 

์ •๋ง ๊ฐ„๋‹จํ•˜์ง€๋งŒ, ์‰ฝ์ง€์•Š์•˜๋˜.... aws phpsdk ์„ค์น˜ ํ•˜๊ธฐ ์ž…๋‹ˆ๋‹ค ใ… .ใ… 

 


1. ์‚ฌ์ „ ์กฐ๊ฑด

 

# EC2 ์ธ์Šคํ„ด์Šค ํ”„๋กœํŒŒ์ผ(role)์„ค์ •

EC2 role ์— ๋ฐ˜๋“œ์‹œ S3 ๊ถŒํ•œ์„ ๋„ฃ์–ด์ค๋‹ˆ๋‹ค

(https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html)




2. aws php sdk ์„ค์น˜

 

# install httpd php 7.2

yum install httpd -y
amazon-linux-extras install php7.2 -y

 

# install php-xml && ์„œ๋น„์Šค ์žฌ์‹œ์ž‘ (์ค‘์š”)!!!

yum install php-xml -y
systemctl restart php-fpm
systemctl restart httpd

 

# install php composer

# 1. ์„œ๋น„์Šค ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™

cd /var/www/html

# 2. ์„ค์น˜

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

# 3. ์ปดํฌ์ € ๋ช…๋ น์–ด๋กœ ์“ธ ์ˆ˜ ์žˆ๋„๋ก ์ด๋™

sudo mv /var/www/html/composer.phar /usr/bin/composer

 

# install aws phpsdk

composer require aws/aws-sdk-php

 

# sample code

 

https://docs.aws.amazon.com/code-samples/latest/catalog/code-catalog-php-example_code-s3.html << ์ถ”์ฒœ

https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-examples-creating-buckets.html

 

# AWS SDK for php Document

 

https://docs.aws.amazon.com/aws-sdk-php/v3/api/

728x90