Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install PHP 8 on Debian 10 - DesignLinux

Jan 01 2021
designlinux 0 Comments
How to Install Php 8 on Debian 10

PHP is a most popular server scripting language used for creating dynamic and interactive Web pages. PHP is widely-used programming language in the Web. This tutorial explains how to install PHP 8.0 on Debian 10 system.

PHP 8.0 is the latest major release and includes performance improvements, and lots of new features such as named arguments, JIT compiler, union types, match expression, and more. By default, Debian 10 ships with PHP version 7.3, which is supported by the most popular CMS and frameworks such as WordPress, Magento, and Laravel. We’ll install PHP from the ondrej/php PPA repository.

Before upgrading to or installing PHP 8, make sure that your applications support it.

Enable PHP Repository#

First of all we need to enable the PHP repository, run the below command:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Now, we can go ahead to install PHP 8.

Install PHP 8.0 with Apache#

Apache is the most used web server in the world. If you’re using Apache as a web server, you can run PHP as an Apache module or PHP-FPM.

Install PHP as Apache Module#

It is very easy task to install Apache Module. Run the below commands:

sudo apt update
sudo apt install php8.0 libapache2-mod-php8.0

After the packages installed, you must restart the Apache to take the effect of changes.

sudo systemctl restart apache2

Configure Apache with PHP-FPM#

Php-FPM is a FastCGI process manager for PHP. Execute the below commands to install:

sudo apt update
sudo apt install php8.0-fpm libapache2-mod-fcgid

PHP-FPM is not enabled in Apache by default, You should enable it by typing:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm

To get the changes, restart Apache:

systemctl restart apache2

Installing PHP 8.0 with Nginx#

By default, Nginx doesn’t have a built-in support for processing PHP files. So we need to use PHP FPM service to handle the PHP files.

Run the following commands to install PHP and PHP FPM packages:

sudo apt update
sudo apt install php8.0-fpm

The FPM service will start automatically, once the installation has been finished. You can check the status of the service by typing:

systemctl status php8.0-fpm
● php8.0-fpm.service - The PHP 8.0 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.0-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-12-20 11:09:17 UTC; 26s ago

After that, you need to edit domain Nginx server block and add following lines to work PHP file using Nginx:

server {

    # . . . other code

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    }
}

Save the configuration file and restart the nginx service for the new configuration take effect:

sudo systemctl restart nginx

Installing PHP Extensions#

You can install PHP extensions as per requirements. You can easily install extensions using apt package manager in following form:

sudo apt install php8.0-[extension]

For example, to install CLI and PDO extensions, you would run the following command:

sudo apt install php8.0-cli php8.0-pdo

Again, restart the Apache or PHP FPM service as per your setup.

Testing PHP#

Once the installation complete, you can verify version by typing:

php --version
PHP 8.0.0RC3 (cli) (built: Nov  27 2020 12:26:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0RC3, Copyright (c), by Zend Technologies

Conclusion#

This tutorial shown you how to install PHP 8.0 and configure with Apache and Nginx on your Debian 10 system.

If you have any questions or feedback, please leave a comment below.

Related

Tags: debian, php

How to Convert PDF to Image in Linux Command Line

Prev Post

How To Migrate Virtualbox VMs Into KVM VMs In Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 503
  • 1,055,275

DesignLinux.com © All rights reserved

Go to mobile version