is it possible to run wordpress on lambda using aws lambda web adapter?

0

My requirement is to deploy serverless wordpress and I have came through concept of lambda web adapter which is for response streaming between lambda and web application. For reference: https://aws.amazon.com/blogs/compute/using-response-streaming-with-aws-lambda-web-adapter-to-optimize-performance/

With that reference, I have created a Dockerfile for install wordpress with lambda web adapter and the dockerfile is below

FROM public.ecr.aws/awsguru/php:82.2023.3.11.1 AS builder
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
COPY app /var/task/app
WORKDIR /var/task/app
RUN composer install --prefer-dist --optimize-autoloader --no-dev --no-interaction
FROM public.ecr.aws/awsguru/php:82.2023.3.11.1
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter
COPY --from=builder /var/task /var/task
ADD nginx/conf/nginx.conf      /opt/nginx/conf/nginx.conf
ADD php/php.ini                /opt/php/php.ini
ADD php/etc/php-fpm.conf       /opt/php/etc/php-fpm.conf
ADD php/php.d/extensions.ini   /opt/php/php.d/extensions.ini
COPY bootstrap /opt/bootstrap
RUN chmod +x /opt/bootstrap
EXPOSE 8080
ENTRYPOINT /opt/bootstrap

I have prepared the docker image , push it to ECR then used SAM Template to deploy image on lambda with api gateway. After deployment, while testing the lambda function it shows execution succeed with 302 status code as follows

{
  "statusCode": 302,
  "headers": {
    "server": "nginx/1.23.3",
    "date": "Fri, 15 Sep 2023 10:22:57 GMT",
    "content-type": "text/html; charset=UTF-8",
    "transfer-encoding": "chunked",
    "connection": "keep-alive",
    "x-powered-by": "PHP/8.2.2",
    "expires": "Wed, 11 Jan 1984 05:00:00 GMT",
    "cache-control": "no-cache, must-revalidate, max-age=0",
    "x-redirect-by": "WordPress",
    "location": "http://127.0.0.1:8080/wp-admin/install.php"
  },
  "multiValueHeaders": {
    "server": [
      "nginx/1.23.3"
    ],
    "date": [
      "Fri, 15 Sep 2023 10:22:57 GMT"
    ],
    "content-type": [
      "text/html; charset=UTF-8"
    ],
    "transfer-encoding": [
      "chunked"
    ],
    "connection": [
      "keep-alive"
    ],
    "x-powered-by": [
      "PHP/8.2.2"
    ],
    "expires": [
      "Wed, 11 Jan 1984 05:00:00 GMT"
    ],
    "cache-control": [
      "no-cache, must-revalidate, max-age=0"
    ],
    "x-redirect-by": [
      "WordPress"
    ],
    "location": [
      "http://127.0.0.1:8080/wp-admin/install.php"
    ]
  },
  "body": "",
  "isBase64Encoded": false
}

and while making request by api url in browser it was redirected to /wp-admin/install.php path but doesn't appear any page.

Url redirected to wp-admin/install.php but page not appear

So give me a solution how to resolve it and tell me is it the right way to deploy serverless wordpress or there is any other method to achieve it.

3 回答
2
已接受的回答

Hi there.

It seems to be possible. These are third party blog posts that can help: Serverless WordPress on AWS Lambda and Serverless WordPress architecture on AWS.

Disclaimer: As noted, these are 3rd party blogs. Neither AWS, Amazon nor me shall be held responsible for its content. Please read and use them at your own risk.

I hope this helps.

profile pictureAWS
专家
已回答 8 个月前
  • Thanks Jose Guay. I refered the blog you said but now I'm facing issue in handler.php file as "PHP Notice: Undefined index: REQUEST_URI in /var/task/handler.php on line 17 PHP Notice: Undefined index: in /var/task/handler.php on line 35 PHP Notice: Undefined index: REQUEST_URI in /var/task/handler.php on line 17 PHP Notice: Undefined index: in /var/task/handler.php on line 35" so can you help me to sort out this.

  • Hello! As noted, the blogs are 3rd party and only intended to illustrate it is possible to do the implementation. I recommend reaching out to the blog owners and post the question to them for follow up.

0

It is possible to host WordPress on Lambda with Lambda Web Adapter. Here is a sample: serverless-woocommerce-workshop.

AWS
已回答 8 个月前
0

It's possible but not necessary, as you can't afford the NAT Gateway fees, it costs 32$ per month. https://www.serverless-wordpress.cloud/2024/01/08/why-not-aws-lambda/

已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则