Directly connect to php-fpm

We can’t just curl to php-fpm because it does not serve HTTP. There is a tool “cgi-fcgi” that can make request to php-fpm to run specified script.

The reason that I have to do this is I running php-fpm in docker container. I set “opcache.validate_timestamps=0” so when there is new updates I need to run opcache_reset() function that can flush opcache without php-fpm reload or restart.

We can’t run opcache_reset() from php-cli, opcache in php-fpm won’t be reset. And I can’t just call through nginx (load balancer). Because there are multiple php-fpm nodes behind.

I have to trigger opcache_reset() on every php-fpm containers so finally I have to do like this.

    docker exec \
     -e SCRIPT_NAME=/opcache_reset.php \
     -e SCRIPT_FILENAME=/var/www/html/opcache_reset.php \
     -e REQUEST_METHOD=GET \
     php-fpm-container \
     cgi-fcgi -bind -connect 127.0.0.1:9000