본문 바로가기

Web Service/AWS

AWS PHP SDK 설치과정(S3 파일 업로드 등)

요약:

1. Compatibility 확인

https://github.com/amazonwebservices/aws-sdk-for-php/tree/master/_compatibility_test/

2. ssl 지원하는 curl 깔기:

sudo apt-get remove --purge php5-curl && \
sudo apt-get install libcurl4-openssl-dev curl-ssl php5-curl

3. APC 설치:

apt-cache search apc

로 검색하여 설치(php-apc)

4. 나머지 component들도 비슷하게 설치...

 AWS SDK for PHP 

PHP Environment Compatibility Test (CLI)

----------------------------------------


PHP 5.2 or newer............  Yes  5.3.10-1ubuntu3.4

64-bit architecture.........  Yes 

cURL with SSL...............  Yes  7.22.0 (OpenSSL/1.0.1)

Standard PHP Library........  Yes 

SimpleXML...................  Yes 

DOM.........................  Yes 

JSON........................  Yes 

PCRE........................  Yes 

File system read/write......  Yes 

OpenSSL extension...........  Yes 

Zlib........................  Yes 

APC.........................  Yes 

XCache......................  No  

Memcache....................  Yes 

Memcached...................  Yes 

PDO.........................  Yes 

SQLite 2....................  No  

SQLite 3....................  No  

PDO-SQLite driver...........  No  

open_basedir disabled.......  Yes 

safe_mode disabled..........  Yes 

Garbage Collector enabled...  Yes 

Valid SSL certificate.......  Yes 


----------------------------------------


 Your environment meets the minimum requirements for using the AWS SDK for PHP! 


* The OpenSSL extension is installed. This will allow you to use CloudFront

  Private URLs and decrypt Windows instance passwords.


* The Zlib extension is installed. The SDK will request gzipped data

  whenever possible.


* Storage types available for response caching:

  The file system, APC, Memcached


----------------------------------------


 Bottom Line: Yes, you can! 


Your PHP environment is ready to go, and can take advantage of all possible features!


 Recommended settings for config.inc.php 


CFCredentials::set(array(

    '@default' => array(

        'key' => 'aws-key',

        'secret' => 'aws-secret',

        'default_cache_config' =>  'apc' ,

        'certificate_authority' =>  false 

    )

));

과 같은 화면 확인하면 설치 완료

5. 기타 configuration은 아래의 내용 참조


Getting Started with the AWS SDK for PHP

Articles & Tutorials>Getting Started with the AWS SDK for PHP
This guide shows you how to start building PHP applications on the Amazon Web Services platform with the AWS SDK for PHP.

Details

Submitted By:Craig@AWS
AWS Products Used:Amazon CloudFront, Amazon EC2, Amazon S3, Amazon SQS, Amazon SimpleDB
Language(s):PHP
Created On:September 27, 2010 5:01 PM GMT
Last Updated:September 29, 2010 1:17 AM GMT

The AWS SDK for PHP helps you get started in minutes using a single, downloadable package. Using the PHP SDK, you can build solutions for many AWS products, such as Amazon Simple Storage Service (Amazon S3), Amazon Elastic Compute Cloud (Amazon EC2), and Amazon SimpleDB.

Get Set Up

To get set up, you must sign up for Amazon Web Services, get your AWS credentials, and set up your environment.

Sign Up for AWS Products

Before you can begin, you must sign up for each AWS product you want to use. The sample included in the SDK uses Amazon S3, so we'll use that product as an example here.

To sign up for a product
  1. Go to the home page for the product, for example aws.amazon.com/s3/

    Tip: Go to aws.amazon.com/products for a list of links to all our products.

  2. Click the sign-up button on the top right corner of the page.
  3. Follow the on-screen instructions. If you don't already have an AWS account, you are prompted to create one as part of the sign-up process.

AWS sends you a confirmation e-mail after the sign-up process is complete. You can view your current account activity or manage your account at any time, by going to aws.amazon.com and clicking the Account tab.

Get Your Credentials

In order to use the AWS SDK for PHP, you need your AWS Access Key ID and Secret Access Key.

To get your AWS Access Key ID and Secret Access Key
  1. Go to http://aws.amazon.com/.
  2. Click Account and then click Security Credentials.
    The Security Credentials page displays (you might be prompted to log in).
  3. Scroll down to Access Credentials and make sure the Access Keys tab is selected.
    The AWS Access Key ID appears in the Access Key column.
  4. To view the Secret Access Key, click Show.

Important! Your Secret Access Key is a secret, which only you and AWS should know. It is important to keep it confidential to protect your account. Store it securely in a safe place. Never include it in your requests to AWS, and never e-mail it to anyone. Do not share it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your Secret Access Key.

Set Up Your Environment

Aside from a baseline understanding of object-oriented programming in PHP, there are a few minimum requirements to start using the AWS SDK for PHP. All the following requirements are common, and most extensions come installed with PHP 5.2 by default. 

Minimum requirements are:

If you're not sure if your PHP installation supports these requirements, you can run the AWS SDK for PHP Compatibility Test. (Alternatively, you can check by either running phpinfo() in a browser or by running php -ifrom the command line.)

To install your PHP environment

  • To use Amazon CloudFront, you must have the OpenSSL PHP extension (which is different from any low-level OpenSSL libraries installed on your system) to sign private CloudFront URLs.
  • To use response caching with the following tools, you must install the associated extensions:
    • APCAPC PHP extension
    • XCacheXCache PHP extension
    • Memcache—Either the older Memcache PHP extension, or the newer Memcached PHP extension
    • SQLite—If PDO support isn't already enabled, install the SQLite 3 PHP extension and the PDO-SQLitedriver

Install the SDK

There are a few ways you can grab the source for the AWS SDK for PHP, each option is described briefly here.

To install the AWS SDK for PHP

  • Choose your installation method from one of the following:
    • Install from downloadable file from http://aws.amazon.com/sdkforphp
    • Install from Git. For more information on Git, explore Git for the lazy, or other Git references.
      git clone git://github.com/amazonwebservices/aws-sdk-for-php.git AWSSDKforPHP
      cd ./AWSSDKforPHP
    • Install from Subversion
      svn co http://svn.github.com/amazonwebservices/aws-sdk-for-php.git AWSSDKforPHP
      cd ./AWSSDKforPHP
    • Install from PEAR
      sudo pear channel-discover pear.amazonwebservices.com
      sudo pear install aws/sdk

Configure the SDK Security Credentials

There are two different ways to configure your credentials: one approach is geared for simplicity, whereas the other is geared for flexibility. The simple approach is preferred for all installation approaches except PEAR. This flexible approach is preferred if you are installing from PEAR; if you need it, find a copy of the config-sample.inc.php file on GitHub.

To add your AWS credentials the simple way (non-PEAR)

  1. Navigate to the config-sample.inc.php file in the SDK directory, and rename it to config.inc.php.
  2. Open config.inc.php for editing. There are instructions in this file for what each configuration value, should be and where you can find it.
  3. When the SDK is loaded, it will first look for config.inc.php in the same directory as sdk.class.php. You are now ready to run the sample!

Caution! Be sure to back up your config.inc.php file when upgrading to avoid having to re-enter your credentials.

To add your AWS credentials the flexible way (PEAR)

  1. Create a new configuration file at ~/.aws/sdk/config.inc.php
    You can either download and copy the contents of a config-sample.inc.php file, or grabdirectly from the above GitHub link.
  2. Open config.inc.php for editing. There are instructions in this file for what each configuration value, and where you can find it.
  3. Enter echo getenv('HOME'); to verify that PHP can access the HOME environment variable .
  4. If the previous command doesn't t return the correct file path to your user directory, configure it withputenv('HOME=<your-user-path>');.

Run the Sample

The AWS SDK for PHP contains sample code demonstrating how to use the AWS SDK for PHP with Amazon S3. The sample creates an Amazon S3 bucket, uploads a number of files from a test-files/ directory in to the bucket, then displays a URL for each file.

Important! Before you run the sample you must configure the SDK with your AWS security credentials. For more information, see Configure the SDK Security Credentials.

To run the Amazon S3 Sample

  • Run the cli-s3_get_urls_for_uploads.php file located in the samples/ folder of the SDK installation directory.

Where Do I Go from Here?

For more information about the AWS SDK for PHP, including a complete list of supported AWS products, go toaws.amazon.com/sdkforphp.

SDK Reference Documentation

The SDK reference documentation includes the ability to browse and search across all code included with the SDK. It provides thorough documentation, usage examples, and even the ability to browse method source. You can find it athttp://docs.amazonwebservices.com/AWSSDKforPHP/latest.

Tutorials and Screencasts

Learn more about using the AWS SDK for PHP from our list of articles, tutorials, and screencasts: