• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install PHP 8 on Ubuntu 20.04

Written by Rahul, Updated on February 2, 2021

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.

  1. Enable PPA – Use the following command
    sudo add-apt-repository ppa:ondrej/php 
    
  2. Update cache – After enabling apt repository, update cache on your system.
    sudo apt update 
    
  3. 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 -v 

PHP 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]

Conclusion

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.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy