Setting up LAMP
LAMP is a collection of open source software that together form a web server.
So let’s break it down to you. LAMP means or comes from (or it’s an acronym of) Linux, Apache, MariaDB and PHP. Where Apache is a web server, MariaDB is a relational database server and PHP is a programming language.
Alternatively: If you don’t like Apache or you are familiar with other popular web server like Nginx, you can install Nginx. Same goes for MariaDB, you can replace it with MySQL, if you want. We don’t discover Nginx or MySQL on this documentation.
In some cases, for example if you are using Ubuntu (server), you can install
lamp-server
usingtasksel
, with the following commandsudo tasksel install lamp-server
. We don’t recommend this, it’s better to install the packages separately or independently. You can thank us later.
How to install Apache
To install Apache on Debian, run the following command.
sudo apt install apache2
You might also want to install the apache2-utils
package.
How to install MariaDB
To install MariaDB on Debian, run the following command.
sudo apt install mariadb-server mariadb-client
Run the mysql secure installation
To launch the installer, run the following command.
mysql_secure_installation
If this is your first time for running the installation, press enter, when asked for a current password, because you don’t probably have a password for root user yet.
Follow these instructions:
Enter current password for root (enter for none):
press enter.
Switch to unix_socket authentication [Y/n]
? answer to this question with ‘n
’.
Change the root password [Y/n]
? answer to this question with ‘Y
‘. Then insert the new password for root.
Remove anonymous users [Y/n]
? answer to this question with ‘Y
‘.
Disallow root login remotely [Y/n]
? answer to this question with ‘Y
‘.
Remove test database and access to it [Y/n]
? answer to this question with ‘Y
‘.
Reload privilege tables now [Y/n]
? answer to this question with ‘Y
‘.
Now the installation is finished.
How to install PHP
To install PHP on Debian, run the following command.
sudo apt install php php-cli libapache2-mod-php php-mysql php-pdo
To install specific PHP version, you can use the following command where you add the version number to the package you wish to install.
sudo apt install php8.2 php8.2-cli libapache2-mod-php8.2... and so on.
Note:
On january 2025: The latest version of PHP is 8.4, so if you wish to install the latest version, you might need to add
ondrej/php DPA
and here is how PHP 8.4.
Additional PHP packages to install
If you wish or plan to install something like Drupal or WordPress, there is a change that you need to install additional packages, these might be the following,
sudo apt install php8.4-gd php8.4-mbstring php8.4-curl php8.4-xml... and so on.
For Windows environments or users
If you are running Windows OS, we recommend you to install XAMPP.
For (web) developers
Running LAMP stack on your local is not always the best solution. The main reason probably is that every time you start a new project or a web site, you need to configure Apache. So it takes some time to set it all up. For local development, we recommend Lando.