1

I'm running a small private Debian Jessie server, acting as a private cloud / hosting platform.

Often times, I've faced 'difficulties' installing services with recent PHP requirements because, while most documentations tell you to call php in a certain manner (to install composer for instance), I actually have to call php5. And if it were just that, I could easily handle it, but I do not always entirely control what binary is used without having to rework lots of scripts and so on.

$ php5 -v
PHP 5.6.20-0+deb8u1 (cli) (built: Apr 27 2016 11:26:05) 
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

$ php -v 
PHP 5.5.15 (cli) (built: Oct  4 2014 14:03:37) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Both binaries point to different versions of PHP, and I don't understand why. When I list my installed packages there's only one php.

php-auth/stable,now 1.6.4-1 all [installed]
php-auth-sasl/stable,now 1.0.6-1+deb8u1 all [installed,automatic]
php-db/stable,now 1.7.14-3 all [installed,automatic]
php-gettext/stable,now 1.0.11-1 all [installed,automatic]
php-http-request/stable,now 1.4.4-4 all [installed,automatic]
php-log/stable,now 1.12.8-2 all [installed,automatic]
php-mail/stable,now 1.2.0-7 all [installed,automatic]
php-mail-mime/stable,now 1.8.9-1+deb8u1 all [installed,automatic]
php-mdb2/stable,now 2.5.0b5-1 all [installed,automatic]
php-net-dime/stable,now 1.0.2-2 all [installed,automatic]
php-net-smtp/stable,now 1.6.2-2 all [installed,automatic]
php-net-socket/stable,now 1.0.14-1 all [installed,automatic]
php-net-url/stable,now 1.0.15-3 all [installed,automatic]
php-pear/stable,now 5.6.20+dfsg-0+deb8u1 all [installed]
php-soap/stable,now 0.13.0-1 all [installed,automatic]
php-tcpdf/stable,now 6.0.093+dfsg-1 all [installed,automatic]
php-xml-parser/stable,now 1.3.4-7 all [installed,automatic]
php5/stable,now 5.6.20+dfsg-0+deb8u1 all [installed]             <--- HERE
php5-apcu/stable,now 4.0.7-1 amd64 [installed]
php5-cgi/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-cli/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-common/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-curl/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-gd/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-imagick/stable,now 3.2.0~rc1-1 amd64 [installed]
php5-imap/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-intl/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-json/stable,now 1.3.6-1 amd64 [installed,automatic]
php5-ldap/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed,automatic]
php5-mcrypt/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-memcache/stable,now 3.0.8-5 amd64 [installed]
php5-memcached/stable,now 2.2.0-2 amd64 [installed]
php5-mysql/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-pgsql/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed,automatic]
php5-pspell/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-readline/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed,automatic]
php5-recode/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-sqlite/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-tidy/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-xmlrpc/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]
php5-xsl/stable,now 5.6.20+dfsg-0+deb8u1 amd64 [installed]

I'm hoping someone can explain why 2 versions of PHP coexist on my server and if there's anyway I can make sure that php points to the php5 package I've installed as a default.

Thank you.

1 Answer 1

1

It is bad, something is not okay in your system.

On the debian way, /usr/bin/php should be a symlink to /etc/alternatives/php, which should be a symlink to /usr/bin/php5. Thus, if you get different version informations for the command php and php5, it is bad.

This alternatives thing enables you to have simultanously different php versions on the same system. For example, you could have php4 and php5. But, different versions of php5, you can't have, these packages are eachothers replacements.

I think, sometimes a source-based, or non-debianic php install happened on your system, which wasted your /usr/bin/php. On debian jessie, it must be a symbolic link as I wrote above.

Your problems result from this. I suggest to remove the non-debian php version, and do a dist-upgrade. Maybe some system cleanup would be also useful, that non-debianic php install probably installed other files as well.

1
  • It's actually less serious than you say but your answer let me find the problem. My PATH was incorrectly pointing to /usr/local/bin before /usr/bin. And for a reason I probably won't ever remember, there's a PHP binary in there. I fixed my path, and now php points back to the correct place and version. Thanks !
    – kRYOoX
    Commented May 17, 2016 at 0:49

You must log in to answer this question.

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