skip to Main Content

I want to install specific version of php for that i write this command sudo apt-get install php7.2 it’s showing like this

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'php7.2-common' for regex 'php7.2'
Note, selecting 'php7.2-sodium' for regex 'php7.2'
Note, selecting 'libapache2-mod-php7.2' for regex 'php7.2'
Note, selecting 'php7.2-thrift' for regex 'php7.2'
0 upgraded, 0 newly installed, 0 to remove and 235 not upgraded.

after this when i want to know the version of php , i run php -v i am getting following error

Command 'php' not found, but can be installed with: sudo apt install php7.4-cli # version 7.4.16-1ubuntu2.1, or sudo apt install php-cli # version 2:7.4+76ubuntu1

2

Answers


  1. Try these steps:

    1: Add Ondrej’s PPA, which contains the PHP 7.2 package:

    sudo add-apt-repository ppa:ondrej/php
    

    2: Update:

    sudo apt update
    

    3: Install PHP 7.2

    sudo apt install php7.2
    

    4: Select the standard version of PHP

    sudo update-alternatives --set php /usr/bin/php7.2
    

    5: Restart Apache2:

    sudo systemctl restart apache2
    
    Login or Signup to reply.
  2. Run the following commands it will work

    sudo apt update
    sudo apt upgrade
    
    sudo apt install ca-certificates apt-transport-https
    
    wget -q https://packages.sury.org/php/apt.gpg -- I sudo apt-key add echo "deb https://packages.sury.org/php/stretch
    
    main" | sudo tee /etc/apt/sources.list.d/php.list 
    sudo apt update
    
    sudo apt install php7.2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search