• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install PHP on Debian 10 Linux

Written by Admin, Updated On January 22, 2020
debian, php
How to Install PHP on Debian 10 Linux

PHP is an open-source and widely used server-side programming language. This guide will walk you through the steps to install PHP 7.3 on Debian 10 Buster.

By default, Debian 10 ships with PHP version 7.3 and it supported in most popular CMS and frameworks such as WordPress, Magento, and Laravel.

Step 1 – Prerequisites#

You must be logged in as root or user with sudo privileges.

Step 2 – Update system#

Update the package index list, it’s recommend to update software repositories and install packages to sync with latest releases.

sudo apt update && sudo apt upgrade

Step 3 – Install PHP on Debian 10#

At this step your system is up to date and ready to install PHP. Run the following command to install PHP 7.3.

Installing PHP with Apache#

sudo apt install php php-common libapache2-mod-php

Installing PHP 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.

sudo apt install php php-common php-fpm

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/php7.3-fpm.sock;
    }
}

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

sudo systemctl restart nginx

Step 4 – Installing PHP Extensions#

You can install PHP extensions as per requirements. Run below command to install most common PHP extensions required for basic usage.

sudo apt install php-cli php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

Step 5 – Testing PHP#

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

php -v
PHP 7.3.3-1 (cli) (built: Mar  7 2019 19:43:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.3-1, Copyright (c) 1999-2018, by Zend Technologies

Conclusion#

You learned how to install PHP on Debian 10 and configure your webserver to process PHP files.

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

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Webmin on CentOS 8
Next Article   How to Add Swap Space on CentOS 8

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook