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. In this tutorial, you will learn the following. So, let’s begin with a tutorial to install and Use PHP 8.0 on Ubuntu 20.04 LTS Focal system.
Step 1 – Install PHP 8 on Ubuntu
The Ondrej PHP PPA is always up to date and contains the latest PHP versions. Use the following commands to add PPA and install PHP 8.0 on Ubuntu 20.04 system. Once completed the above commands, you have successfully installed PHP 8.0 on the Ubuntu system.
Step 2 – Installing PHP Extensions
Now, install the required PHP modules for your application. Use the following command to search all available PHP 8.0 modules. Then install the required PHP modules. The following command will install some frequently used PHP modules on your system. You may also need to install other PHP modules recommended by the application.
Step 3 – Install PHP 8 with Apache
Apache is a popular web server widely used for deploying PHP web applications. On Debian-based systems this is available with the name “apache2”. An Apache module is available to integrate PHP. For PHP 8.0 install the following Apache module Then enable PHP 8 module All done, now your can host a PHP application with Apache using PHP 8. To test the integration, create a phpinfo() file and verify the version.
Step 4 – Install PHP 8 with Nginx
There is no official PHP module for the Nginx server. In that case, we will use PHP-FPM to deploy PHP applications over Nginx web servers. So, first, install PHP fpm on your system. Once the installation is finished, enable and start the service. Next, update the Nginx server block configuration with the following code. The above code instructs the Nginx server to process all files with the “.php” extension using PHP-fpm. Finally, restart the Nginx webserver to apply the changes.
Step 5 – Switch Default PHP Version
You can easily switch between multiple PHP version installed on any system. Execute the following command on terminal: This system has PHP 8.0 and PHP 7.4 installed. Select a PHP version on our choice.
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.