From 0d2b1116e29ac7fdea8ad89f308a1a3efd188dd5 Mon Sep 17 00:00:00 2001 From: Andy Max Date: Mon, 9 May 2022 15:43:13 +0100 Subject: [PATCH 1/3] Fixed issues builing PHP 7.3 --- README.md | 11 +++++++---- build-php-remi.sh | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f71456d..4b1de29 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ + # PHP Layer For AWS Lambda +> Forked to fix issues building the layer + Ever wanted to run PHP websites in AWS Lambda? It's your lucky day! This Lambda Runtime Layer runs the [PHP 7.3/7.1 webserver](http://php.net/manual/en/features.commandline.webserver.php) in response to [AWS API Gateway](https://aws.amazon.com/api-gateway/) or [AWS Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/features/#Details_for_Elastic_Load_Balancing_Products) requests. And, if you're looking for a great way to build serverless apps of all kinds, be sure to check out [Stackery](https://stackery.io)! @@ -196,8 +199,8 @@ If you are behind a proxy server, just set the environment variable `http_proxy` invoking `make`, eg.: ```sh - $ export http_proxy=http://myproxy.acme.com:8080 - $ make php73.zip + $ export http_proxy=http://myproxy.acme.com:8080 + $ make php73.zip ``` #### Debugging Layer Builds @@ -205,13 +208,13 @@ invoking `make`, eg.: Run: ```sh - $ docker run --rm -it -v `pwd`:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash + $ docker run --rm -it -v `pwd`:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash ``` If you are on Windows, run this instead: ```sh - > docker run --rm -it -v %cd%:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash + > docker run --rm -it -v %cd%:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash ``` then manually execute the commands in the build.sh file. diff --git a/build-php-remi.sh b/build-php-remi.sh index 8d8fbef..73bb8cc 100755 --- a/build-php-remi.sh +++ b/build-php-remi.sh @@ -6,9 +6,9 @@ echo "Building layer for PHP 7.$PHP_MINOR_VERSION - using Remi repository" yum install -y wget yum install -y yum-utils -wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm -wget https://rpms.remirepo.net/enterprise/remi-release-6.rpm -rpm -Uvh epel-release-latest-6.noarch.rpm +wget https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm +wget https://rpms.remirepo.net/enterprise/remi-release-6.rpm --no-check-certificate +rpm -Uvh epel-release-6-8.noarch.rpm rpm -Uvh remi-release-6.rpm yum-config-manager --enable remi-php7${PHP_MINOR_VERSION} @@ -16,7 +16,7 @@ yum-config-manager --enable remi-php7${PHP_MINOR_VERSION} yum install -y httpd yum install -y postgresql-devel yum install -y libargon2-devel - +yum install -y oniguruma5php yum install -y --disablerepo="*" --enablerepo="remi,remi-php7${PHP_MINOR_VERSION}" php php-mbstring php-pdo php-mysql php-pgsql php-xml php-process @@ -36,7 +36,7 @@ done cp /usr/lib64/libedit.so.0 lib/ cp /usr/lib64/libargon2.so.0 lib/ cp /usr/lib64/libpq.so.5 lib/ -cp /usr/lib64/libonig.so.5 lib/ +cp /usr/lib64/libonig.so.105 lib/ mkdir -p lib/php/7.${PHP_MINOR_VERSION} cp -a /usr/lib64/php/modules lib/php/7.${PHP_MINOR_VERSION}/ From 1f0930710c6ec51e825970f6192d19816608e092 Mon Sep 17 00:00:00 2001 From: Andy Max Date: Tue, 10 May 2022 09:45:27 +0100 Subject: [PATCH 2/3] Added PHP 7.4 --- Makefile | 13 +++++++++++-- README.md | 2 +- build-php-74.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 build-php-74.sh diff --git a/Makefile b/Makefile index eee5fce..fd88e12 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -all: php71.zip php73.zip +all: php71.zip php73.zip php74.zip php71.zip: docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-provided /opt/layer/build.sh @@ -8,18 +8,27 @@ php71.zip: php73.zip: docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-provided /opt/layer/build-php-remi.sh 3 +php74.zip: + docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-provided.al2 /opt/layer/build-php-74.sh + upload71: php71.zip ./upload.sh 7.1 upload73: php73.zip ./upload.sh 7.3 +upload74: php74.zip + ./upload.sh 7.4 + publish71: php71.zip ./publish.sh 7.1 publish73: php73.zip ./publish.sh 7.3 +publish74: php74.zip + ./publish.sh 7.4 + clean: - rm -f php71.zip php73.zip + rm -f php71.zip php73.zip php74.zip diff --git a/README.md b/README.md index 4b1de29..0632015 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PHP Layer For AWS Lambda -> Forked to fix issues building the layer +> Forked to fix issues building the layer and added PHP 7.4 Ever wanted to run PHP websites in AWS Lambda? It's your lucky day! This Lambda Runtime Layer runs the [PHP 7.3/7.1 webserver](http://php.net/manual/en/features.commandline.webserver.php) in response to [AWS API Gateway](https://aws.amazon.com/api-gateway/) or [AWS Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/features/#Details_for_Elastic_Load_Balancing_Products) requests. diff --git a/build-php-74.sh b/build-php-74.sh new file mode 100755 index 0000000..1440fe9 --- /dev/null +++ b/build-php-74.sh @@ -0,0 +1,43 @@ +#!/bin/bash -e + +PHP_MINOR_VERSION=4 + +echo "Building layer for PHP 7.$PHP_MINOR_VERSION - using amazon linux extras repository" + +yum install -y amazon-linux-extras wget yum-utils +amazon-linux-extras enable php7.4 +yum clean metadata + +yum install -y php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap} + +yum install -y httpd postgresql-devel libargon2-devel oniguruma5php + +mkdir /tmp/layer +cd /tmp/layer +cp /opt/layer/bootstrap bootstrap +sed "s/PHP_MINOR_VERSION/${PHP_MINOR_VERSION}/g" /opt/layer/php.ini >php.ini + +mkdir bin +cp /usr/bin/php bin/ + +/usr/bin/php -v + +ls -lh /lib64/ + +mkdir lib +for lib in libncurses.so.6 libtinfo.so.6 libpcre.so.1; do + cp "/lib64/${lib}" lib/ +done + +ls -lh /usr/lib64/ + +cp /usr/lib64/libedit.so.0 lib/ +#cp /usr/lib64/libargon2.so.0 lib/ +cp /usr/lib64/libpq.so.5 lib/ +cp /usr/lib64/libonig.so.2 lib/ + +mkdir -p lib/php/7.${PHP_MINOR_VERSION} +cp -a /usr/lib64/php/modules lib/php/7.${PHP_MINOR_VERSION}/ + +zip -r /opt/layer/php7${PHP_MINOR_VERSION}.zip . + From 34e1981e7928b782d824d89a804e381be2e8f18a Mon Sep 17 00:00:00 2001 From: Andy Max Date: Tue, 10 May 2022 09:47:26 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0632015..0b5b7cd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ And, if you're looking for a great way to build serverless apps of all kinds, be This is an early iteration of the PHP runtime Layer which is not yet ready for production. Please feel free to use this Layer to learn about the Lambda Layers feature and begin experimenting with PHP functions. We welcome feedback and stay tuned for the production-ready version coming soon. ## Current Layer Version ARN + +> The Stackery layers are no longer available. You must now build the layer yourself and adding the layer to your own AWS account. + When creating/updating a Lambda function you must specify a specific version of the layer. This readme will be kept up to date with the latest version available. The latest available Lambda Layer Version ARNs for PHP 7.3 and 7.1 are: **arn:aws:lambda:\:887080169480:layer:php73:3**