How to
PHP 7
Install PHP 7.4 - Ubuntu below 20.04
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt -y install php7.4 php7.4-xml composer php7.4-mbstringPHP 8
Install PHP 8.0 - Ubuntu
sudo add-apt-repository ppa:ondrej/php --force-yes
sudo apt-get update ; \
sudo apt install php8.0-common php8.0-cli -y
php -v # Show PHP version.
php -m # Show PHP modules loaded.Install additional extensions
An example to install a few more useful extensions:
For development environments, code coverage tools or the Xdebug debugger can be installed as well.
Purge old PHP versions
If the new installation is working as expected, you can remove the old PHP packages from the system.
This assumes you are using PHP 7.4 as the previous version. Change php7.4 part of the command above with the appropriate PHP version.
References
Install Pear
Commands
PHP Built-in Server
Interactive mode
Set Default value for env vars
Generate BCrypt hash
Execute Shell Script from PHP
Working with Dates
Use PHPCS globally
Installing globally PHPCS
Know your path
Add the line below into your
~/.zshrcou~/.bashrc
array_map to utf8_encode
Last updated
Was this helpful?