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:

[email protected]:~# 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:

[email protected]:~# 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:

[email protected]:~# 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:

[email protected]:~# apache2 -v
Server version: Apache/2.4.38 (Debian)
Server built:   2019-10-15T19:53:42
[email protected]:~#

Check service status.

systemctl status apache2

Output:

[email protected]:~# 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:

[email protected]:~# 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:

[email protected]:~# 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

Create a php script to test your LAMP stack installation.

echo "<?php phpinfo(); ?>" | tee /var/www/html/phpinfo.php

Output:

[email protected]:~# echo "<?php phpinfo(); ?>" | tee /var/www/html/phpinfo.php
<?php phpinfo(); ?>
[email protected]:~#

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

Example.