Alex W Alex W - 1 year ago 139
PHP Question

CentOS 6.8 PHP-FPM not working correctly with PHP CLI

I have spent the last day Googling this, and either my Google-Fu is having a bad day or no-one has asked this before.

These past couple of days I have been setting up a Vagrant VM with CentOS 6.8 for me to work on our website. I decided to install the same packages which are on our live server: Nginx, PHP-FPM & Percona. I removed PHP 5.3 and enabled 5.6 in the remi repo and currently have installed:

  • php.x86_64 (5.6.25-1.el6.remi)

  • php-cli.x86_64 (5.6.25-1.el6.remi)

  • php-common.x86_64 (5.6.25-1.el6.remi)

  • php-fpm.x86_64 (5.6.25-1.el6.remi)

  • php-mbstring.x86_64 (5.6.25-1.el6.remi)

  • php-mcrypt.x86_64 (5.6.25-1.el6.remi)

  • php-mssql.x86_64 (5.6.25-1.el6.remi)

  • php-mysqlnd.x86_64 (5.6.25-1.el6.remi)

  • php-pdo.x86_64 (5.6.25-1.el6.remi)

  • php-pecl-jsonc.x86_64 (1.3.10-1.el6.remi.5.6)

  • php-pecl-zip.x86_64 (1.13.4-1.el6.remi.5.6)

  • php-xml.x86_64 (5.6.25-1.el6.remi)

Now at this point I was not aware of any issues as the website was running perfectly fine. However today I went to reindex the site, we are using Magento so I do it through CLI out of preference. The command is:

php indexer.php reindexall

All this outputed was:

Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p ] [-g ] [-c ] [-d foo[=bar]] [-y ] [-D] [-F [-O]]
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-h This help
-i PHP information
-m Show compiled in modules
-v Version number
-p, --prefix
Specify alternative prefix path to FastCGI process manager (default: /usr).
-g, --pid
Specify the PID file location.
-y, --fpm-config
Specify alternative path to FastCGI process manager config file.
-t, --test Test FPM configuration and exit
-D, --daemonize force to run in background, and ignore daemonize option from config file
-F, --nodaemonize
force to stay in foreground, and ignore daemonize option from config file
-O, --force-stderr
force output to stderr in nodaemonize even if stderr is not a TTY
-R, --allow-to-run-as-root
Allow pool to run as root (disabled by default)

I have never seen this happen. There were no errors in terminal or even in the log. I tried other php scripts I had and even created a really simple "hello world" test which I knew would run, but still got the same output. So I did some digging and after a while noticed my
php -v
PHP 5.6.25 (fpm-fcgi)
instead of
PHP 5.6.25 (cli)

I tried removing the php-fpm package, which then fixed the output of
php -v
, and enabled my simple test script to run, however that's not really a fix as that leaves me without php-fpm.

I really hope this is just a simple setting I have missed as it obviously works fine on our live server. I did ask our host support and they haven't seen it before either.

So, after all that background, I suppose the short question is how to install php-fpm without it conflicting with php-cli?

Answer Source

Try using the full path to the desired PHP executable. Something like:

/usr/bin/php indexer.php reindexall

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download