Install PHP and Apache2 on Debian Buster

Here I will explain how to install PHP 7.3 on Debian Buster. If you to want to install another version of PHP, you only should change in all places where PHP 7.3 it is, for the version you to want to install. I will also explain how to install apache2.

Login as root and write you Password.

su -

Update your package list, instead of apt-get we will use apt.

# apt update

1- Install ca-certificates, apt-transport-https, lsb-release, curl, aptitude wget y unzip .

The command

apt install ca-certificates apt-transport-https aptitude lsb-release wget curl unzip -y

2- Download the public key (OpenPGP Key) from and add it to your Debian folder, as Debian advises.

The command

wget -O /usr/share/keyrings/apt.gpg

3- Now we are going to add the public key (OpenPGP Key) to our sources.list.d, so you will always have your PHP updated, we do it as Debian says.

The command

 sh -c 'echo "deb [signed-by=/usr/share/keyrings/apt.gpg] $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list'

4- Update you Debian

apt update

You have to know that PHP version you want to install, I will use as an example of installation php7.3

5- Sometimes missing PHP modules for Apache Apache, libapache2-mod-php7.3 , we install it.

The command

apt install libapache2-mod-php7.3

6- Install Apache2 server

The command

apt install apache2 -y

7- Install PHP, I repeat, I install the php7.3 version, if you want another one, you have to change for the version number you want to have.

The command

 apt install php7.3 php7.3-cli php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-readline php7.3-xml php7.3-xsl php7.3-zip php7.3-bz2 libapache2-mod-php7.3 -y

8- Check if you have installed the version php7.3, write,

php --version

You'll see a window telling you which version you are using. It will look like this.

vesion de php que tengo instalada

9- Create a phpinfo file. It will display you with more detailed information about your PHP configuration.

With nano write this address /var/www/html which is the default route that the most popular web servers use, as an example, apache2, and phpinfo is the common name for the file, anyway, you can use a different name.

The command

sudo nano /var/www/html/phpinfo.php

A blank file will open, copy this code and add it to the file.



To save it, we press the Ctrl + O keys and press the ↵ enter key to enter.

To exit from nano we press the keys

Crtl + X

Restart apache2

systemctl restart apache2

You have to connect to your virtual network interface, Loopback, for display, this file, typing in your web browser, in the address bar, localhost and phpinfo.php


And if everything went well, you will get a window like this

vconfiguraci贸n de php

You comment is welcome: