0

I would like to spawn two php-fpm processes (one with xdebug and one without) to make pages load faster

I intend to switch between php-fpm sockets based on the XDEBUG_SESSION cookie

Example code /etc/apache2/conf-available/php7.2-fpm.conf

<FilesMatch ".+\.ph(ar|p|tml)$">
  <If "%{HTTP_COOKIE} =~ /XDEBUG_SESSION=PHPSTORM/">
          SetHandler "proxy:fcgi://127.0.0.1:9000"
  </If>
  <Else>
          SetHandler "proxy:fcgi://127.0.0.1:9001"
  </Else>
</FilesMatch>

I know how to configure php-fpm /etc/php/7.2/fpm/pool.d/www.conf

listen = 127.0.0.1:9000

But I have no idea how to spawn multiple (or just two) php-fpm processes.
If there is a simpler way, please let me know.

unloco
  • 121
  • 1
  • 6

2 Answers2

1

Make a second php-fpm pool with the changed settings that you want. You only have one which you named www. Choose a different name for the second one.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • But I read somewhere that you can't unload a php extension in a pool because the parent process already loaded it, I ended up using docker-compose to sort of switch between containers conditionally – unloco Nov 14 '20 at 00:23
0

I ended up using docker-compose to switch between containers conditionally

https://github.com/unlocomqx/conditional-xdebug-fpm-docker

Inspired by https://jtreminio.com/blog/developing-at-full-speed-with-xdebug/

Here are the interesting parts

Two separate php containers each with a different port and one without xdebug

  php:
    build:
      context: ./bin/php72-fpm
    container_name: '${COMPOSE_PROJECT_NAME}-${PHPVERSION}'
    volumes:
      - ${DOCUMENT_ROOT-./www}:/var/www/html
    ports:
      - "9000:9000"
  php_xdebug:
    build:
      context: ./bin/php72-xdebug
    container_name: '${COMPOSE_PROJECT_NAME}-xdebug-${PHPVERSION}'
    volumes:
      - ${DOCUMENT_ROOT-./www}:/var/www/html
    ports:
      - "9002:9002"
unloco
  • 121
  • 1
  • 6