10

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?

1 Answer 1

22

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

You must log in to answer this question.

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