How to Install PHP 8.0 on Debian 11 bullseye Linux

Install PHP 8.0 on Debian 11

PHP is one of the most used server-side programming languages.

In this guide, we will discuss how to install PHP 8.0 on Debian 11 Bullseye. We’ll also show you how to integrate PHP with Nginx and Apache.

Debian 11 bullseye ships with PHP version 8.0, which is supported by the most popular CMS and frameworks such as WordPress, Magento, and Laravel.

Prerequisites

To be able to install packages, you need to be logged in as root or user with Sudo privileges.

Installing PHP with Apache on Drebian 11 Bullsyeye

If you are using Apache as your webserver to install PHP and Apache PHP module run the following commands:

sudo apt updatesudo apt install php libapache2-mod-php

Once the installation is complete, restart Apache to load the PHP module:

sudo systemctl restart apache2

Installing PHP with Nginx on Drebian 11 Bullsyeye

Unlike Apache, Nginx doesn’t have a built-in support for processing PHP files. You’ll need to use the PHP FPM (“fastCGI process manager”) service to handle the PHP files.

Install the PHP and PHP FPM packages by running the following command:

sudo apt updatesudo apt install php php-fpm

Once the packages are installed, the PHP FPM service will start automatically.

You can now edit your domain 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/php7.3-fpm.sock;
    }
}

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

sudo systemctl restart nginx

Debian 11 Bullseye Download Now

Installing PHP extensions on Drebian 11 Bullsyeye

You can extend the PHP core functionalities by installing additional extensions. PHP extensions are available as packages and can be easily installed by typing:

sudo apt install php-[extname]

For example, to install MySQL and GD PHP extensions, you would run the following command:

sudo apt install php-mysql php-gd

When installing PHP extensions, do not forget to restart the Apache or the PHP FPM service, depending on your setup.

Testing PHP Processing

To test whether your web server is properly configured for PHP processing, create a new file called info.php inside the /var/www/html directory with the following code:/var/www/html/info.php

<?php

phpinfo();

Save the file, open your browser of choice and visit http://your_server_ip/info.php

The phpinfo function prints information about your PHP configuration as shown on the image below:

Install PHP 8.0 on Debian 11 bullseye Linux

Conclusion

We have shown you how to install PHP on Debian 10 and configure your webserver to process PHP files.

If you have any questions or feedback, do not hesitate to leave a comment.

Be the first to comment

Leave a Reply

Your email address will not be published.


*