PHP is an acronym of “Hypertext Preprocessor” is a scripting language widely used for developing web applications. It is the server side scripting language that is embedded in HTML. Which is used to manage dynamic content, databases, session tracking, even build entire e-commerce websites.
PHP 8.0 is the latest stable version available for production use. The debian packages for PHP 8 is available under ppa:ondrej/php PPA for Ubuntu systems.
This tutorial will help you to install PHP 8.0 on Ubuntu 20.04 LTS Focal system.
Step 1 – Installing PHP 8 on Ubuntu
Use the following commands to add PPA and install PHP 8.0 on Ubuntu 20.04 system.
- Enable PPA – Use the following command
sudo add-apt-repository ppa:ondrej/php
- Update cache – After enabling apt repository, update cache on your system.
sudo apt update
- Installing PHP – Next, install the PHP 8.0 on Ubuntu system.
sudo apt install php8.0
Press ‘Y’ for any confirmation asked by the installer.
Once completed above commands, you have successfully installed PHP 8.0 on Ubuntu system.
Step 2 – Installing PHP Modules
Now, install the required PHP modules for your application. Use the following command to search all available PHP 8.0 modules.
sudo apt search php8.0-*
Then install the required PHP modules. The following command will install some frequently used php modules on your system.
sudo apt install php8.0-gd php8.0-xml php8.0-soap php8.0-mbstring php8.0-mysql
Step 3 – View PHP Version
Now use the following command to check installed PHP version on your system. You can also use other methods to check PHP version.
php -vPHP 8.0.1 (cli) (built: Jan 13 2021 08:22:35) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.1, Copyright (c) Zend Technologies with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies
Step 4 – Switch Default PHP Version
You can easily switch between multiple PHP version installed on any system. Execute the following command on terminal:
sudo update-alternatives --config php
This system has PHP 8.0 and PHP 7.4 installed. Select a PHP version on our choice.
There are 2 choices for the alternative php (providing /usr/bin/php). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/php8.0 80 auto mode 1 /usr/bin/php7.4 74 manual mode 2 /usr/bin/php8.0 80 manual mode Press
to keep the current choice[*], or type selection number: [ENTER CHOICE HERE]
This tutorial helps you to install PHP 8.0 on Ubuntu 20.04 Linux system. You may also need to install MySQL on your Ubuntu system.