Table of Contents

Local LAMP dev environment installation

How to install a localhost development environment with PHP, Apache and MariaDB

This simple guide is intended for Debian GNU/Linux and derivates (Ubuntu, Mint). You need to be root (sudo) for most of the listed commands.

Base installation

$ apt install apache2 curl php php-bcmath php-cli php-curl php-gd php-imagick php-imap php-intl php-mbstring php-mysql php-sqlite3 php-xml php-zip composer

Config files for PHP are then located in /etc/php/8.x/.

MariaDB (MySQL)

$ apt install mariadb-server mycli

PHPMyAdmin

$ apt install phpmyadmin

During that installation an interactive dialogue opens where you have to select apache2, then dbconfig-common settings launches automatically where you will create the main database and password.

The settings get saved to these locations: /etc/dbconfig-common/phpmyadmin.conf and /etc/phpmyadmin/config-db.php

Then open your web browser and you should have access to: http://localhost/phpmyadmin/, enter “phpmyadmin” as username and you previously chosen password.

Useful system commands

Start MariaDB:

$ systemctl start mariadb

Make MariaDB start automatically during system boot:

$ systemctl enable mariadb

Show Apache status:

$ systemctl status apache2

Restart Apache:

$ systemctl restart apache2 (older way: service apache2 restart)

Add and remove PHP modules, here with xdebug module as an example:

$ phpenmod xdebug
$ phpdismod xdebug

After each PHP module change it's necessary to reload the Apache server:
$ systemctl reload apache2 (it's not necessary to restart it completely)

Footnote:
Another (but older) how-to article can be found here.