3

I know php-fpm isn't intended to be used from bash as much as, say, php-cli, but I'm making a common interface for my website from both my broswer and the command line, and I need the executing version to be exactly the same.

echo '<?php echo 1' | socat - UNIX-CLIENT:/var/run/php/php7.2-fpm.sock

doesn't work, but I guess it is maybe because I don't extract the output, but either way I wouldn't know how to do that.

Any idea ?

4
  • 2
    Why can't you just ensure that the php.ini for both php-fpm and php-cli are the same? Commented Jan 26, 2018 at 9:14
  • I could, but that would make me unable to see php-fpm-related errors. dumb things such as php service turned off. Commented Jan 26, 2018 at 9:46
  • Use other mechanisms to monitor your PHP-FPM service. Commented Jan 26, 2018 at 16:43
  • That isn't an option, because it lets users wrongly use the deployed solution on other servers. Commented Jan 26, 2018 at 22:42

1 Answer 1

2

You should not. As @Barmar pointed out in the comments, just ensure php-cli has the same php.ini file loaded as php-fpm. Then just call php from bash. For me, the solution in an docker environment was to add the last line in this example docker-compose.yml

    php-fpm:
        build: phpdocker/php-fpm
        working_dir: /app
        environment:
            PHP_IDE_CONFIG: "serverName=Docker"
        volumes:
            - '../xy:/xy'
            - './phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/8.1/fpm/conf.d/99-overrides.ini'
            - './phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/8.1/cli/conf.d/99-overrides.ini'

Where /phpdocker/php-fpm/php-ini-overrides.ini is my custom ini file.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh boy, time flies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.