Articles with tag - aws

Extending a Linux File System after Resizing the Volume

Posted on 3 years ago by Ping Cheng

Article source: AWS

This is a log to keep a note to help me on resizing the linux file system in the future. The steps are :

adjust the volume on the AWS, and wait for the complete of volume resizing process

check if the disk was resized

lsblk

extend the disk

sudo growpart /dev/xvdf 1

resize the volume to the new capacity (I am using the xfs file system, other file systems command may be different)

sudo xfs_growfs -d /mnt

check the new volume size

df -h

Upload file to Amazon S3 via PHP

Posted on 2 years ago by Ping Cheng

Before all steps, I assume you are met these prerequisite:

  • Using .env file (link)
  • Using Composer
  • Amazon access key id and secret ready
  1. Install Amazon SDK via Composer
composer require aws/aws-sdk-php
  1. Adding these information to your .env environment file
AWS_ACCESS_KEY_ID=*your key*
AWS_SECRET_ACCESS_KEY=*your secret access*
AWS_REGION=*your s3 bucket region*
AWS_BUCKET=*your bucket name*
  1. Upload the file to bucket

$file = $_FILES['filename'];

$provider = \Aws\Credentials\CredentialProvider::env(); // load the credentials info from the env file
$region = getenv('AWS_REGION'); // setup the region
$bucket = getenv('AWS_BUCKET');  // setup the bucket name

// create a new s3 instance
$s3 = new \Aws\S3\S3Client([
    'version' => 'latest',
    'region' => $region,
    'credentials' => $provider
]);
$random_filename = md5(time()); // create 

...

[ Read More ]

Search
Hand crafted with by Ping Cheng