Join the community today
Become a Member

Confused about PHP shell path

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by deltahf, Oct 5, 2021.

Tags:
  1. deltahf

    deltahf Premium Member Premium Member

    490
    216
    43
    Jun 8, 2014
    Ratings:
    +383
    Local Time:
    7:17 AM
    I am confused about PHP install locations and my shell PATH. Apparently I have multiple versions of PHP installed on this new server:

    Code (Text):
    $ php -v
    PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17)
    Copyright (c) 1997-2013 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    


    Code (Text):
    $ which php
    /bin/php
    


    Of course I can see where Centminmod installed the latest version of PHP:
    Code (Text):
    $ /usr/local/bin/php -v
    PHP 7.4.24 (cli) (built: Oct  4 2021 05:01:48) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
    



    I'm using the same .bashrc file as I was on my old server where this wasn't a problem — and I've never had it happen before when installing Centminmod — so I'm a bit confused.

    Of course, I don't want or need 5.4 installed. What would be the best way for me to fix this so I can just run "php" and always use the latest installed version?

    Can I just delete /bin/php?
     
  2. eva2000

    eva2000 Administrator Staff Member

    47,843
    10,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,957
    Local Time:
    10:17 PM
    Nginx 1.21.x
    MariaDB 10.x
    That's strange maybe PHP 5.4 the default CentOS 7 YUM packages ?

    what's output for
    Code (Text):
    yum -q provides */bin/php

    and if any YUM packages return from that output listthe YUM packages via yum history to see when they were added
    Code (Text):
    yum history list YUMPACKAGENAME
     
  3. deltahf

    deltahf Premium Member Premium Member

    490
    216
    43
    Jun 8, 2014
    Ratings:
    +383
    Local Time:
    7:17 AM
    Ah, OK, we might be getting somewhere...

    Code (Text):
    $ yum -q provides */bin/php
    php-cli-5.4.16-48.el7.x86_64 : Command-line interface for PHP
    Repo        : base
    Matched from:
    Filename    : /usr/bin/php
    
    
    
    rh-php70-php-cli-7.0.10-2.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php70/root/usr/bin/php
    
    
    
    rh-php70-php-cli-7.0.27-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php70/root/usr/bin/php
    
    
    
    rh-php70-php-cli-7.0.27-2.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php70/root/usr/bin/php
    
    
    
    rh-php71-php-cli-7.1.8-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php71/root/usr/bin/php
    
    
    
    rh-php71-php-cli-7.1.30-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php71/root/usr/bin/php
    
    
    
    rh-php71-php-cli-7.1.30-2.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php71/root/usr/bin/php
    
    
    
    rh-php72-php-cli-7.2.10-3.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php72/root/usr/bin/php
    
    
    
    rh-php72-php-cli-7.2.24-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php72/root/usr/bin/php
    
    
    
    rh-php73-php-cli-7.3.7-2.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php73/root/usr/bin/php
    
    
    
    rh-php73-php-cli-7.3.11-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php73/root/usr/bin/php
    
    
    
    rh-php73-php-cli-7.3.20-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php73/root/usr/bin/php
    
    
    
    rh-php73-php-cli-7.3.29-1.el7.x86_64 : Command-line interface for PHP
    Repo        : centos-sclo-rh
    Matched from:
    Filename    : /opt/rh/rh-php73/root/usr/bin/php
    
    
    
    php-cli-5.4.16-48.el7.x86_64 : Command-line interface for PHP
    Repo        : @base
    Matched from:
    Filename    : /usr/bin/php
    


    Here we go...

    Code (Text):
    $ yum history list php-cli-5.4.16-48.el7.x86_64
    Loaded plugins: fastestmirror, langpacks, priorities, versionlock
    ID     | Command line             | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
        45 | install phoronix-test-su | 2021-10-04 03:35 | Install        |    8
    


    The rest with the rh-php7* prefix don't have a history:

    Code (Text):
    $ yum history list rh-php73-php-cli-7.3.29-1.el7.x86_64
    Loaded plugins: fastestmirror, langpacks, priorities, versionlock
    Bad transaction IDs, or package(s), given
    Error: Failed history list
    


    I did install the Phoronix test suite yesterday while I was tinkering with benchmarks, so I guess that explains it. Ugh. Can it be fixed?
     
  4. eva2000

    eva2000 Administrator Staff Member

    47,843
    10,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,957
    Local Time:
    10:17 PM
    Nginx 1.21.x
    MariaDB 10.x
    You can either uninstall just php-cli or the entire phoronix suite

    Either
    Code (Text):
    yum remove php-cli

    Or entire suite by reversing the yum history transaction ID = 45 which is probably better so you remove all packages that Phoronix installed
    Code (Text):
    yum history undo 45
     
  5. deltahf

    deltahf Premium Member Premium Member

    490
    216
    43
    Jun 8, 2014
    Ratings:
    +383
    Local Time:
    7:17 AM
    Whoa, that is cool. :eek: Shows how much I know... didn't realize you could do that with yum.

    It fixed the issue for me. Cheers!

    Code (Text):
    $ php -v
    PHP 7.4.24 (cli) (built: Oct  4 2021 05:01:48) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
    
     
  6. eva2000

    eva2000 Administrator Staff Member

    47,843
    10,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,957
    Local Time:
    10:17 PM
    Nginx 1.21.x
    MariaDB 10.x
    Yes yum history command is a powerful tool when used correctly :D