简体   繁体   English

CentOS 6.8 PHP-FPM无法与PHP CLI一起正常使用

[英]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. 我已经度过了这一天的最后一天,或者我的Google-Fu日子不好过,或者没有人问过这个问题。

These past couple of days I have been setting up a Vagrant VM with CentOS 6.8 for me to work on our website. 在过去的几天里,我一直在使用CentOS 6.8设置Vagrant VM,以便我可以在我们的网站上工作。 I decided to install the same packages which are on our live server: Nginx, PHP-FPM & Percona. 我决定在实时服务器上安装相同的软件包:Nginx,PHP-FPM和Percona。 I removed PHP 5.3 and enabled 5.6 in the remi repo and currently have installed: 我删除了PHP 5.3,并在remi repo中启用了5.6,目前已安装:

  • php.x86_64 (5.6.25-1.el6.remi) php.x86_64(5.6.25-1.el6.remi)
  • php-cli.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-common.x86_64(5.6.25-1.el6.remi)
  • php-fpm.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-mbstring.x86_64(5.6.25-1.el6.remi)
  • php-mcrypt.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-mssql.x86_64(5.6.25-1.el6.remi)
  • php-mysqlnd.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-pdo.x86_64(5.6.25-1.el6.remi)
  • php-pecl-jsonc.x86_64 (1.3.10-1.el6.remi.5.6) 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-pecl-zip.x86_64(1.13.4-1.el6.remi.5.6)
  • php-xml.x86_64 (5.6.25-1.el6.remi) 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. 但是今天我去重新索引该站点,因为我们使用的是Magento,所以我不希望通过CLI进行操作。 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. 我尝试了其他的php脚本,甚至创建了一个非常简单的“ hello world”测试,该测试我知道该测试可以运行,但仍然得到相同的输出。 So I did some digging and after a while noticed my php -v showed PHP 5.6.25 (fpm-fcgi) instead of PHP 5.6.25 (cli) . 所以我做了一些挖掘,过了一会儿我的php -v显示PHP 5.6.25 (fpm-fcgi)而不是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. 我尝试删除php-fpm软件包,然后修复了php -v的输出,并使我的简单测试脚本能够运行,但是这并不是一个真正的解决方案,因为我没有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? 因此,在所有这些背景之后,我想一个简短的问题是如何在不与php-cli冲突的情况下安装php-fpm?

Try using the full path to the desired PHP executable. 尝试使用所需PHP可执行文件的完整路径。 Something like: 就像是:

/usr/bin/php indexer.php reindexall

I don't understand where you /usr/sbin/php comes from 我不明白您的/ usr / sbin / php来自哪里

# rpm -q php-cli php-fpm
php-cli-5.6.25-1.el6.remi.x86_64
php-fpm-5.6.25-1.el6.remi.x86_64

# which php
/usr/bin/php

# php -v
PHP 5.6.25 (cli) (built: Aug 31 2016 19:26:19) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

# rpm -qf /usr/sbin/php
error: file /usr/sbin/php: No such file or directory

So you can probably just remove it. 因此,您可以将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM