-2

I am a new Linux Mint user. In my computer I found PHP version 7.1 from phpinfo() like below

enter image description here

I found PHP version 7.4.3 from terminal like below

enter image description here

My /etc/php/ folder is like below

enter image description here

Which PHP version am I using ?

abu abu
  • 6,599
  • 19
  • 74
  • 131
  • 2
    CLI != apache ... you're using 7.4 on cli and 7.1 on your webserver – treyBake Feb 24 '20 at 10:16
  • 1
    You are using both. Former's configured to handle requests that come from Apache, the latter's configured for PHP scripts running from CLI. – revo Feb 24 '20 at 10:18
  • 1
    Try to run `sudo a2dismod php7.1` and `sudo a2enmod php7.4` to increase PHP version from 7.1 to 7.4 in apache web server. As above - version for CLI and Apache are two different things – Krzysztof Raciniewski Feb 24 '20 at 10:18
  • Thanks @treyBake. I need to install Mcrypt PHP extension. What should be my command in this regard ? – abu abu Feb 24 '20 at 10:58

4 Answers4

1

Try in your terminal

which php

your will find your terminal PHP path.

Shahadat Hossain
  • 947
  • 9
  • 24
1

You have multiple versions installed and you're using the version that PHP tells you you are using.

When you use the webserver module version of PHP it is version 7.1.33. When you use the command line version you are using 7.4.3.

You might also have 7.0 and 7.2 installed (or they may be folders for leftover config files in versions that have since been uninstalled).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks @Quentin. I need to install Mcrypt PHP extension. What should be my command in this regard ? – abu abu Feb 24 '20 at 10:55
  • 1
    @abuabu — Depends on how you installed PHP in the first place and which PHP you want to install the module for (and I probably won't know the answer if you do tell me those and its a rather different problem to the one you originally asked here). – Quentin Feb 24 '20 at 10:57
  • Thanks @Quentin. Actually I don't know how I installed PHP in the first place and which PHP I want to install the module for. I made another question in SO. May be you can get an idea from there. https://stackoverflow.com/questions/60372913/how-to-install-mcrypt-php-module Thanks. – abu abu Feb 24 '20 at 11:01
1

Disable php 7.1 module on Apache

sudo a2dismod php7.1

and enable php 7.4

sudo a2enmod php7.4
sudo systemctl restart apache2
Salines
  • 5,674
  • 3
  • 25
  • 50
  • Thanks @Salines. I need to install Mcrypt PHP extension. What should be my command in this regard ? – abu abu Feb 24 '20 at 10:56
1

The php version used by the CLI and the one used by apache CAN be different.
The installed versions are listed in your /etc/php/ folder as you already emntioned.

To switch the used version for apache you can use the following commands:

sudo a2dismod php7.1
sudo a2enmod php7.4

Also you have to restart your apache afterwards.

Reference: https://serverfault.com/questions/149039/how-to-change-what-version-of-php-apache2-uses

Spears
  • 2,102
  • 1
  • 17
  • 27