BANDA ACEH - Install PHP 8 on Ubuntu 20.04. This guide let you learn how install the latest PHP version 8 and upgrade to latest on your Ubuntu 20.04 or 18.04 systems or your Ubuntu server on any VPS or any Cloud or any Dedicated hosting and configure it with Apache and Nginx.
The latest PHP 8 is officially released on November 26th, 2020. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.
This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. This set up will work on all Linux servers.
If you are using Google Cloud Platform to install PHP you need the following steps to be done.
Make sure your Ubuntu server is having the latest packages by running the following command.
This will update the package index and update the installed packages to the latest version.
Add the ondrej/php which has PHP 8 package and other required PHP extensions.
Once you have added the PPA you can install PHP 8.
Execute the following command to install PHP 8
After the installation has completed, you can confirm the installation using the following command
For Nginx you need to install FPM, execute the following command to install PHP 8 FPM
After the installation has completed, confirm that PHP 8 FPM has installed correctly with this command
Installing PHP extensions are simple with the following syntax.
Now, install some commonly used php-extensions with the following command.
Now we configure PHP for Web Applications by changing some values in php.ini file.
For PHP 8 with Apache the php.ini location will be in following directory.
Hit F6 for search inside the editor and update the following values for better performance.
Once you have modified your PHP settings you need to restart your Apache for the changes to take effect.
For PHP 8 FPM with Nginx the php.ini location will be in following directory.
Hit F6 for search inside the editor and update the following values for better performance.
Once you have modified your PHP settings you need to restart PHP FPM for the changes to take effect.
PHP 8 FPM allows you to configure the user and group that the service will run under. You can modify these with these commands
Change the following lines by replacing the www-data with your username.
Hit CTRL+X and Y to save the configuration and check if the configuration is correct and restart PHP.
Once you have updated your PHP FPM settings you need to restart it to apply the changes.
Now you are having PHP 8 Installed and configured.
Once you have installed PHP 8 you need to upgrade to the latest installed version of PHP.
You need to disable the old PHP version and enable the new PHP version 8.
This command will disable the PHP 7.4 module.
This command will enable the PHP 8 module.
Now you need to restart Apache for the changes to take effect.
For Nginx you need to update the PHP-FPM socket in your Nginx configuration located inside the sites-available directory. This will be located inside the location block location ~ \.php$
Edit your configuration…
The line you need to modify will look like this…
You need to replace the old PHP version with the new version.
Test your configuration and restart Nginx.
Now you have learned how to install PHP 8 and upgrade your configuration on your Ubuntu server.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.
Please share by clicking this button!
Visit our site and see all other available articles!