AWS Lambda for PHP - Compiling Runtime | Uploading PHP Layers | Creating Test Function

Опубликовано: 13 October 2024
на канале: SheltieCoder
1,421
13

AWS Lambda for PHP

Video 2 of 30
Compile PHP Custom Bootstrap Layer
Upload your Custom Bootstrap Layer to AWS
Uploading Vendor and Runtime Folders
Creating Lambda AWS Test Function

Bootstrap used in this video:
https://www.dropbox.com/s/yx8amxf8do5...

Commands used in this video:

sudo yum update -y && sudo yum install autoconf bison gcc gcc-c++ libcurl-devel libxml2-devel -y && curl "https://awscli.amazonaws.com/awscli-e..." -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install && sudo yum group install 'Development Tools' -y && sudo yum install perl-core zlib-devel -y && cd /usr/local/src/ && sudo wget https://www.openssl.org/source/openss... && sudo tar -xf openssl-1.0.2u.tar.gz && cd openssl-1.0.2u && cd /usr/local/src/openssl-1.0.2u && sudo ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && sudo make && sudo make install && cd ~ && mkdir ~/php-8.2.12-source && curl -sL https://www.php.net/distributions/php... | tar -xvz && cd php-8.2.12-source && cd ~/php-8.2.12/ && ./buildconf --force && sudo yum install oniguruma-devel -y && sudo yum install sqlite-devel -y && PKG_CONFIG_PATH="/usr/local/ssl/lib/pkgconfig/" ./configure --prefix=/home/ec2-user/php-8.2.12-source --with-openssl=/usr/local/ssl --with-curl --with-pdo-mysql --with-pdo --with-mysqli --enable-mbstring --enable-soap && sudo make install && mkdir -p ~/lambda-root/{bin,src,lib}/ && cd ~/lambda-root && touch ./bootstrap && chmod +x ./bootstrap && cp ~/php-8.2.12-source/bin/php ./bin && curl -sS https://getcomposer.org/installer | ./bin/php && ./bin/php composer.phar require guzzlehttp/guzzle && ./bin/php composer.phar require aws/aws-sdk-php && ./bin/php composer.phar require phpzip/phpzip && cp /usr/local/src/openssl-1.0.2u/libcrypto.so.1.0.0 lib/ && cp /usr/local/src/openssl-1.0.2u/libssl.so.1.0.0 lib/ && cp /usr/lib64/libonig.so.* lib/ && cp /usr/lib64/libm.so.* lib/

-- edit bootstrap file --

zip -r runtime.zip lib bin && zip -r vendor.zip vendor/

aws configure

aws lambda publish-layer-version \
--layer-name php-runtime-layer \
--zip-file fileb://runtime.zip \
--region eu-north-1

aws lambda publish-layer-version \
--layer-name php-vendor-layer \
--zip-file fileb://vendor.zip \
--region eu-north-1