Installation of a LAMP server on Ubuntu


In this tutorial we will explain how to easily install a LAMP server on an Ubuntu base system.

LAMP means:

L = Linux / A = APACHE / M = MySQL / P = PHP

Installation of the required packages

We begin with the installation of the required packages for the web server by typing the following command:

sudo apt-get install apache2 php7.2 mysql-server php7.2-mysql libapache2-mod-php7.2

After validating the command, the terminal will ask you to confirm the installation of the required dependencies:

During the installation, the administrator password for MySQL has to be entered, pay attention to what you are entering.

Once the installations have finished, you need to start the web server with the command:

 sudo /etc/init.d/apache2 start 

This is what you will see in your terminal:

Apache 2 web server is the application that will allow you to make your site visible, but it can only serve static websites in HTML.

This is where PHP takes over, it will support dynamic pages in PHP.

mysql-server is the database server, many web applications use databases for the storage of their data.

As for the last two packets they allow PHP related to MySQL and Apache.

To test PHP quickly a phpinfo.php file should be created like this:

 cd /var/www/html
 nano phpinfo.php 

copy the following code:

 <? phpinfo(); ?> 

If everything went well, you should see a configuration page of PHP when you open http://yourserversipaddress/phpinfo.php in your browser.

The default configuration uses the folder /var/www/html for accessing the files of your website. This means, you should put all the files you want to have visible on the Internet in this folder.

This documentation guides you through setting up a “turnkey” web server, if you want to customize your installation we invite you to redirect you to the official documentation of the applications:

For Apache :

For PHP :

For MySQL :