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


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:

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

FROM 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
COPY /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
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": ""
  "multiValueHeaders": {
    "server": [
    "date": [
      "Fri, 15 Sep 2023 10:22:57 GMT"
    "content-type": [
      "text/html; charset=UTF-8"
    "transfer-encoding": [
    "connection": [
    "x-powered-by": [
    "expires": [
      "Wed, 11 Jan 1984 05:00:00 GMT"
    "cache-control": [
      "no-cache, must-revalidate, max-age=0"
    "x-redirect-by": [
    "location": [
  "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.

1 Answer
Accepted Answer

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
answered 11 days ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions