How to install a LAMP environment + PhpMyAdmin

Atualizado em 2026-10-27 12:01:26 116 visitas

In this tutorial we will explain how you can obtain a LAMP (Linux, Apache, MySQL and PHP) environment by following a few simple steps. Additionally, we will also teach you how to install PhpMyAdmin so that you can configure and manage your databases directly from the web browser.

What is a LAMP environment?

"LAMP" is the acronym formed from the following words "Linux", "Apache", "MySQL" and "PHP".

Specifically, each of these initials refers to a technology that allows hosting and running web applications. We detail them below:

  • Linux: is the server's operating system.
  • Apache: is a program that manages "web requests". That is, what is popularly known as a web server.
  • MySQL: is a database management system that allows managing, creating, and modifying databases that will store your application's information.
  • PHP: is a programming language in which your application will be programmed.

The LAMP environment or "LAMP Stack" is possibly one of the most popular and widely used technology combinations by web applications such as WordPress and PrestaShop.

How to install a LAMP environment

To be able to have our LAMP environment (an indispensable requirement for installing web applications that require these technologies), it will be necessary to have a Cloud server with Linux. We recommend the "Debian" or "Ubuntu" distributions.

Once our Linux server is deployed, we will already have the first technology of this environment. Next, we will see how to install the rest: Apache, MySQL and PHP.

info From now on, this manual will assume that you have knowledge of SSH, how to execute commands from the terminal in Linux, and that you are using the "Ubuntu 18.04" distribution. Other systems may present variations, especially CentOS or RedHat.

1. Update the operating system:

First, it is recommended to ensure that all operating system packages are updated. To do this, we will execute the following command with superuser permissions:

apt-get update && apt-get upgrade

During the update process, user intervention may be requested. This will depend on the packages being updated and the response will depend on each circumstance. In most cases, the default configuration can be chosen.

2. Install Apache

Installing apache is simple and only requires the following command:

apt-get install apache2

In case any type of confirmation is requested, we simply need to grant it by pressing Y and then space.

The previous command will install and configure the Apache web server with the default parameters.

3. Install MySQL

At this point, it is important to highlight that we will want to install the MySQL server. That is, the program in charge of managing and serving the databases. Likewise, we should also highlight that throughout this manual we have spoken of "MySQL". The latest version of Ubuntu, in reality, uses the "MariaDB" database management system. However, this difference is transparent and harmless to the user regarding this manual and the installation or operation of the LAMP environment.

apt-get install mysql-server

Later, we will use the PhpMyAdmin application to finish configuring the databases and create an administrator user.

4. Install PHP

The PHP language can be installed in a very similar way to all previous installations:

apt-get install php

In Ubuntu 18.04, the version of PHP that will be installed by default is 7.2.

Summary

Following the previous steps, we will already have a LAMP environment, although it may be necessary to perform some type of configuration or adjustment for each of these components, according to the requirements of our web application, project, etc.

How to install PhpMyAdmin

Finally, we will proceed with the installation of PhpMyAdmin. This is a web application that will allow us to manage our databases directly from the browser, something that is practical and convenient.

The installation of PhpMyAdmin is, possibly, the most complex step of the entire manual, as it requires user intervention. Please read carefully the steps we will detail below:

1. Start the installation

apt-get install phpmyadmin

2. Choose the web server

info Read the instructions carefully. It is easy to make a mistake in this step and the installation of PhpMyAdmin cannot be completed correctly.

Next, you must choose which server you want PhpMyAdmin to use. You must mark the apache2 option by pressing the space key.

It is important that the checkbox to the left of the word apache2 is marked with an asterisk: *.

Once you have marked the box, press the tab key to highlight the <OK> button and finally, confirm your selection by pressing the ENTER key.

3. Create the PhpMyAdmin's own database

Next, the installer will give us the option to activate the configuration and install the PhpMyAdmin's own database with the default parameters. Unless you have experience with PhpMyAdmin, we recommend that you choose this option.

Confirm the option by pressing Enter on the <YES> option.

4. Define the password for the PhpMyAdmin administrator user

Finally, you must define a password that will be assigned to the administrator user. Remember that it is recommended that this password contains at least 10 characters, including numbers, lowercase letters, uppercase letters, and symbols. Since it is a web app, you must choose a sufficiently strong password to avoid unauthorized access.

5. Make your first login to PhpMyAdmin

Finally, open a web browser and go to the following URL:

http://<your-server-ip>/phpmyadmin

If you have correctly followed the configuration steps, you should see the PhpMyAdmin welcome screen. To finish, you only have to log in with the following details:

  1. Username: phpmyadmin
  2. Password: the-password-you-have-defined

Summary

If you have followed the steps of this manual, you will now have a fully functional LAMP environment, ready to install any application that requires this stack of technologies. Remember that you may need to make additional adjustments and configurations specific to the characteristics of your project. For example, the configuration of the Apache Virtual Hosts.