How to install LAMP stack on debian 10 buster.

Update debian 10 buster

apt update && apt -y upgrade

To install MaridaDB database server.

apt install -y mariadb-server mariadb-client

Check the status of mariaDB database server

systemctl status mariadb

Output:

root@my:~# systemctl status mariadb
● mariadb.service - MariaDB 10.3.17 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset:
Active: active (running) since Sat 2019-11-02 11:12:09 EDT; 12min ago
Docs: man:mysqld(8)

Run the command below to secure your database server,

mysql_secure_installation

Using the above command, you can do the following,

  • Setting root password

  • Removing anonymous users

  • Disabling remote login for root user

  • Removing test database and access to it

You can log in as your root user and set up a regular user and a database.

mysql -u root -p

Output:

root@my:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.17-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT VERSION();
+---------------------------+
| VERSION()                 |
+---------------------------+
| 10.3.17-MariaDB-0+deb10u1 |
+---------------------------+
1 row in set (0.000 sec)
MariaDB [(none)]>

Install apache web server

apt install -y apache2 apache2-utils

Output:

root@my:~# apt install -y apache2 apache2-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
dh-python libbind9-140 libdns162 libicu57 libisc160 libisccc140 libisccfg140
liblwres141 libperl5.24 libpython3.5-minimal libpython3.5-stdlib

Check apache build and version

apache2 -v

Output:

root@my:~# apache2 -v
Server version: Apache/2.4.38 (Debian)
Server built:   2019-10-15T19:53:42
root@my:~#

Check service status.

systemctl status apache2

Output:

root@my:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
Active: active (running) since Sat 2019-11-02 11:40:41 EDT; 4min 10s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 3554 (apache2)

Restart service when a change is made && enable the service to start at boot.

systemctl reload apache2
systemctl enable apache2

Open server IP address on your browser(http://) to see default Apache page.

Example

Install PHP on debian 10 buster

apt install php libapache2-mod-php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

Output:

root@my:~# apt install php libapache2-mod-php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath              Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.3-common' instead of 'php-pdo'
The following packages were automatically installed and are no longer required:
dh-python libbind9-140 libdns162 libicu57 libisc160 libisccc140 libisccfg140 liblwres141 libperl5.24 libpython3.5-minimal   libpython3.5-stdlib

Enable Apache module if not already enabled then restart the Web Server.

a2enmod php7.3 

Confirm the PHP version

php -v

Output:

root@my:~# php -v
PHP 7.3.11-1~deb10u1 (cli) (built: Oct 26 2019 14:14:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

To test PHP scripts we need to add info.php file in the document.

nano /var/www/html/info.php

Add the following in the file.

<?php phpinfo(); ?>

To view the PHP info on your browser, http://IP_address/info.php

Example.