How To Install PHP 8 On Ubuntu 20.04 - Linuxize
How To Install PHP 8 On Ubuntu 20.04 - Linuxize
04
Updated Dec 5, 2020 • 3 min read
PHP is one of the most widely used server-side programming languages. Many popular CMS
and frameworks such as WordPress, Magento, and Laravel are written in PHP.
PHP 8.0 is the latest major release of the PHP language. It introduces several breaking
changes, performance improvements, and lots of new features such as named arguments,
JIT compiler, union types, match expression, and more.
This article will show you how to install PHP 8 on Ubuntu 20.04 and integrate it with Nginx
and Apache.
At the time of writing, the default Ubuntu 20.04 repositories include PHP 7.4 version. We’ll
install PHP from the ondrej/php PPA repository.
Before upgrading to or installing PHP 8, make sure that your applications support it.
The same steps apply for Ubuntu 18.04 and all Ubuntu-based distribution, including
Kubuntu, Linux Mint, and Elementary OS.
Once the packages are installed, restart Apache for the PHP module to get loaded:
Php-FPM is a FastCGI process manager for PHP. Run the following command to install the
necessary packages:
Run the following commands to install PHP and PHP FPM packages:
Once the installation is completed, the FPM service will start automatically. To check the
status of the service, run
Output
You can now edit the Nginx server block and add the following lines so that Nginx can
process PHP files:
server {
# . . . other code
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}
}
Do not forget to restart the Nginx service so that the new configuration takes effect:
For example, to install MySQL and GD extensions, you would run the following command:
After installing a new PHP extension, do not forget to restart Apache or PHP FPM service,
depending on your setup.
/var/www/html/info.php
<?php
phpinfo();
You’ll see information about your PHP configuration similar to the following:
Conclusion
Installing PHP 8 on Ubuntu 20.04 server is a simple task. All you need to do is to enable the
“ondrej/php” repository and install PHP 8 with apt .
php ubuntu
BUY ME A COFFEE
Related Articles
JUN 17, 2020
JUN 9, 2020
© 2021 Linuxize.com
Privacy Policy Terms Contact Advertise on Linuxize