PHP toolcase

Getting information

Display installed versions

To list the installed versions you can use the command:

sudo update-alternatives --list php

Display installed modules

This will display installed modules for default PHP:

php -m

Interactive shell

You can run the interactive shell from any terminal:

php -a

Install PHP

Core install

Add repository:

sudo add-apt-repository ppa:ondrej/php

Update repository:

sudo apt update

Install PHP core (module for apache is optional):

sudo apt install php8.0 libapache2-mod-php

Module install

sudo apt install openssl php8.0 php8.0-bcmath php8.0-mbstring php8.0-xml php8.0-curl php8.0-zip php8.0-mysql

Test PHP

Test PHP is running correctly:

php -r 'echo "Hello world";'