How to set up a LAMP + PhpMyAdmin environment
In this tutorial we will explain how you can get a LAMP (Linux, Apache, MySQL and PHP) environment by following a few simple steps. In addition, we will also show you how to install PhpMyAdmin so that you can configure and manage your databases directly from your 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 you to host and run web applications. Here are the details:
-
Linux: is the server operating system.
-
Apache: is a program that manages "web requests". That is to say, what is popularly known as web server.
-
MySQL: is a database management system that allows you to manage, create and modify databases that will store the information of your application.
-
PHP: it is a programming language in which your application will be programmed.
The LAMP environment or "LAMP Stack " is possibly one of the most popular technology combinations used by web applications such as WordPress and PrestaShop.
How to install a LAMP environment
In order to have our LAMP environment (essential requirement to install web applications that require these technologies) it will be necessary to have a Cloud server with Linux. We recommend "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 about SSH, about how to execute commands from the terminal in Linux and that you are using the "Ubuntu 18.04" distribution. Other systems may have variations, especially CentOS or RedHat.
1. Upgrading the operating system:
First of all, it is advisable to ensure that all the operating system packages are up to date. To do this, run the following command with superuser permissions:
apt-get update && apt-get upgrade
During the upgrade process, it is possible that user intervention may be requested. This will depend on the packages taht being upgraded and the response will depend on each circumstance. In most cases you will be able to opt for the default configuration.
2. Install Apache
Installing apache is simple and only requires the following command:
apt-get install apache2
In case we are asked for any kind of confirmation, we simply need to confirm by pressing Y
and then space
.
The above command will install and configure the Apache web server with the default parameters.
3. Install MySQL
At this point it is important to note that we will want to install the MySQL server. That is to say, the program in charge of managing and serving the databases. Likewise, we must also emphasize that throughout this manual we have been talking about "MySQL ". The latest version of Ubuntu actually uses the database management system "MariaDB ". However, this difference is transparent and harmless to the user in terms of 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 default PHP version to be installed is 7.2.
Summary
Following the previous steps we will already have a LAMP environment, although it may be necessary to make some kind of configuration or adjustments to each of these components, according to the requirements of our web application, project, etc.
How to install PhpMyAdmin
Finally, we will proceed to the installation of PhpMyAdmin. It 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 whole manual, as it requires user intervention. Please read the following steps carefully:
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 at this step and you may not complete the installation of PhpMyAdmin properly.
Next, you will need to choose which server you want PhpMyAdmin to use. You should check the apache2
option by pressing the space key
.
It is important that the box to the left of the word apache2
is marked with an asterisk: *
.
Once you have checked the box, press the tab key
to highlight the <OK>
button and finally, confirm your selection by pressing the ENTER key
.
3. Create your own PhpMyAdmin database
Next, the installer will give you the option to activate the configuration and install your own PhpMyAdmin database with the default settings. Unless you are experienced with PhpMyAdmin we recommend that you choose this option.
Confirm the option by pressing Enter Key
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 this is a web app, you should choose a strong enough password to avoid unauthorized access.
5. Make your first login to PhpMyAdmin
Finally, open a web browser and go to the following URL:
http://<ip-of-your-server>/phpmyadmin
If you have followed the configuration steps correctly, you should see the PhpMyAdmin welcome screen.
To finish, you just need to login with the following data:
-
User: phpmyadmin
-
Password: the-password-you-defined
Summary
If you have followed the steps in this manual, you will now have a fully functional LAMP environment, ready to install any application that requires this technology stack. 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.