9

I write a script to create new vhost on Nginx. That script creates Ningx vhost config file, vhost user and dirs, php-fpm pool file.

At the end of the script, I would like to check if config is ok before restart php-fpm. For Apache, I do apachectl graceful, but is it possible to do something similar with php5-fpm -t?

20

From the manpage:

  --test
  -t             Test FPM configuration file and  exit  If  called  twice
                 (-tt), the configuration is dumped before exiting.

php5-fpm -t should exit with code 0 if the config is valid, and a non-zero exit code if not. Your script should do something like this then:

if ! php5-fpm -t; then
    echo "php5-fpm configuration is invalid"
    exit 1
fi

However, I made some changes to my configuration which weren't picked up as invalid, so YMMV.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.