Verification: a143cc29221c9be0

Php cli is not enabled

Check PHP Version (CLI)

By default there can be one default PHP version can used with standard binary. To check PHP version currently active on command line, execute the following command on terminal:

php -v 

PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies

On Ubuntu and Debian systems, you can also access other version by pointing their versions like: php7.2 or php7.3 etc.

  • Install PHP on Ubuntu 20.04
  • Install PHP on CentOS 8
  • Install PHP on Debian 10

Checking for installed php modules and packages

In addition to running

php -m

to get the list of installed php modules, you will probably find it helpful to get the list of the currently installed php packages in Ubuntu:

sudo dpkg --get-selections | grep -v deinstall | grep php

This is helpful since Ubuntu makes php modules available via packages.

You can then install the needed modules by selecting from the available Ubuntu php packages, which you can view by running:

sudo apt-cache search php | grep "^php5-"

Or, for Ubuntu 16.04 and higher:

sudo apt-cache search php | grep "^php7"

As you have mentioned, there is plenty of information available on the actual installation of the packages that you might require, so I won't go into detail about that here.

Enable PHP Modules

Use phpenmod command followed by module name to enable specific PHP module on your system. In below example, the first command is an example and the second command will enable mbstring module for all installed PHP versions and all SAPI.

### Syntaxphpenmod MODULE_NAME

### Enable mbstring php modulephpenmod mbstring

You can also define the PHP version using -v switch to enable specific modules. Using this you will enable module for all SAPI.

### Syntaxphpenmod -v ### Enable module for specific php versionphpenmod -v 5.6 mbstring
phpenmod -v 7.4 mbstring

Use -s switch to define the SAPI to enable specific modules for specific SAPI for all PHP versions.

### Syntaxphpenmod -s ### Enable module for specific SAPIphpenmod -s cli mbstring
phpenmod -s fpm mbstring
phpenmod -s apache2 mbstring

You can also define both the PHP version and SAPI for the more specific update.