YouTube Icon

Code Playground.

How to Install PHP on Debian 10 Linux


How to Install PHP on Debian 10 Linux

PHP is one of the most utilized worker side programming dialects. 

In this guide, we will examine how to introduce PHP on Debian 10, Buster. We'll likewise tell you the best way to incorporate PHP with Nginx and Apache. 

Debian 10 boats with PHP rendition 7.3, which is upheld by the most well known CMS and systems, for example, WordPress, Magento, and Laravel. 


To have the option to introduce bundles, you should be signed in as root or client with sudo benefits . 

Installing PHP with Apache 

In the event that you are utilizing Apache as your webserver to introduce PHP and Apache PHP module run the accompanying orders: 

sudo apt update
sudo apt install php libapache2-mod-php

When the establishment is finished, restart Apache to stack the PHP module: 

sudo systemctl restart apache2

Installing PHP with Nginx

Not at all like Apache, Nginx doesn't have an underlying help for preparing PHP documents. You'll have to utilize the PHP FPM ("fastCGI measure administrator") administration to deal with the PHP documents. 

Introduce the PHP and PHP FPM bundles by running the accompanying order: 

sudo apt update
sudo apt install php php-fpm

When the bundles are introduced, the PHP FPM administration will begin naturally. 

You would now be able to alter your area Nginx worker square and include the accompanying lines so Nginx can handle PHP documents: 

server {

    # . . . other code

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

Spare the arrangement document and restart the nginx administration for the new design produce results: 

sudo systemctl restart nginx

Installing PHP extensions

You can expand the PHP center functionalities by introducing extra expansions. PHP augmentations are accessible as bundles and can be effortlessly introduced by composing: 

sudo apt install php-[extname]

For instance, to introduce MySQL and GD PHP expansions, you would run the accompanying order: 

sudo apt install php-mysql php-gd

When introducing PHP expansions, remember to restart the Apache or the PHP FPM administration, contingent upon your arrangement. 

Testing PHP Processing

To test whether your web worker is appropriately designed for PHP handling, make another document called info.php inside the/var/www/html registry with the accompanying code: 




Spare the document, open your program of decision and visit http://your_server_ip/info.php 

The phpinfo work prints data about your PHP arrangement as appeared on the picture underneath: 


We have told you the best way to introduce PHP on Debian 10 and arrange your webserver to handle PHP documents. 

In the event that you have any inquiries or input, don't spare a moment to leave a remark.