Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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