0

I'm developing my application with 2 containers: apache and php-fpm.

Apache serves requests, and delegates PHP execution to the php-fpm container in its vhost:

    <FilesMatch .php$>
        SetHandler "proxy:fcgi://myapp-php-fpm:9000"
    </FilesMatch>

The two containers share a single volume that contains the application code.

The location of that volume is different in each of the containers:

  • apache mounts the app code volume at /home/wwwdata/myapp
  • php-fpm mounts the app code volume at /var/task

How can I change the script path that Apache sends to the php-fpm container, so that it matches where the volume is mounted in the php-fpm container?


I can do this in nginx by setting SCRIPT_FILENAME and DOCUMENT_ROOT:

        location ~ ^/index\.php(/|$) {
          fastcgi_pass myapp-php-fpm:9000;
          fastcgi_split_path_info ^(.+\.php)(/.*)$;
          include fastcgi_params;

          fastcgi_param SCRIPT_FILENAME /var/task/$fastcgi_script_name;
          fastcgi_param DOCUMENT_ROOT /var/task;

          internal;
        }

but I haven't been able to replicate this behavior in Apache.

1 Answer 1

1

Use ProxyFCGISetEnvIf to set the SCRIPT_FILENAME:

    <FilesMatch .php$>
        ProxyFCGISetEnvIf "true" SCRIPT_FILENAME "/var/task%{reqenv:SCRIPT_NAME}"
        SetHandler "proxy:fcgi://myapp-php-fpm:9000"
    </FilesMatch>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .