Install PHP, Apache2, Mysql and Adminer 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, Mysql and Adminer.




Install PHP


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 https://packages.sury.org and add it to your Debian folder, as Debian advises.

The command

wget -O /usr/share/keyrings/apt.gpg https://packages.sury.org/php/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] https://packages.sury.org/php/ $(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 Apache2, 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.


<?php
     
 phpinfo(); 

?>

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

localhost/phpinfo.php

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

vconfiguraci贸n de php


Install MySQL


If you want to install MySQL together with MariaDB look at this Link to see incompatibility issues between versions.

Here the installation will be done without root privileges, so you have to leave root by pressing the keys

Crtl + D


Install the latest version of MySQL, download from the MySQL website the repositories in your browser. Find the Download button in the lower right corner and click.

download last Mysql

A window will open. On this page, you will be asked to log in or sign up for an Oracle web account. We ignore these options and move the mouse where it says No thanks, start my download, here without pressing the mouse, we click on the right part of the mouse and click Copy link address,

copy link to download last Mysql

I have this, https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb

With the Terminal, we open the tmp folder

The command

cd /tmp

With wget we download it in this folder, do not forget to write the version you copied in the previous step, mine is mysql-apt-config_0.8.14-1_all.deb.

The command

/tmp$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb

Now we install our deb with sudo dpkg -i, write the version you downloaded.

The command

sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb

A window will open, the first options are the default option. It will install the standard installation. MySQL Server && Cluster installation (Currently selected: mysql-8.0), It will install the version that tells you, mysql-8.0, move the key where it says, Ok, and you press the Enter key, and the application will follow.

installation of mysql, the estandar version


If you want another version of Mysql, press the key Enter

choose the version which you to want to install

It will ask you to choose which version of MySQL you want to install, move with the key and when you have chosen an option, give the key

and in Aceptar you give the key Enter .

choose which mysql want you to install

You will return to the previous window, move to where it says Ok, press the key Enter and the installation will continue.

Update debian

sudo apt-get update

Install mysql-server

sudo apt-get install mysql-server

It will ask you to enter a root password

ask for a root password

It will ask you to retype the root password

retype the root password

It tells you that Mysql-8.0 uses a new method to encrypt passwords based on SHA256, press the key

and in Aceptar you give the key Enter .

window to say that it is a new method to encrypt passwords based on SHA256

Ask what authentication plugin you want as default, choose the first one, press the key

and press the Enter key, and the installation will continue.

ask what authentication plugin you want as standard

View if Mysql is install

$ mysqladmin -u root -p version

Mysqladmin is a command which allows to perform some basic administrative functions on the MySQL server, -u root tells mysqladmin to enter on MySQL as a root user, -p to ask the client for a password. Information about the version of Mysql which we have installed will appear.

If everything went well, your terminal would look like this,

show on terminal all is install


Mysql Administrator


Debian Buster comes without phpMyAdmin in its repositories, because for more than a year and a half it has not been updated, Bug-Report Nr. 916310, Debian gives as an alternative to the installation of phpMyAdmin, Adminer. Although the website is in English, Adminer it´s also available in more languages. On its website compares, the Admine advantages over phpMyAdmin.


Install Adminer

sudo apt-get install adminer

We create in Adminer the .conf file. With this file, we will connect to apache2.

With nano writen

sudo nano /etc/adminer/adminer.conf

Write to file

Alias /adminer "/usr/share/adminer/adminer"

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


Now in apache2, we tell it to connect to this file, with nano we open the apache2 configuration file.

sudo nano /etc/apache2/apache2.conf

At the end of the file, we write this

Include /etc/adminer/adminer.conf

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


With this, we will have finished.


Update apache2

sudo service apache2 restart

Now, we can connect to Adminer from our browser, type in your Web Browser, in the address bar,

localhost/adminer


If everything went well, your browser would look like this,

ventana principal de adminer









You comment is welcome: