How to install LAMP on Ubuntu Server

Granaja of servers that can have LAMP in their guts

Despite the fact that in the Desktop world there are several Gnu / Linux distributions and very varied, the same does not happen in the Server world and only a little of these stand out or are used to manage the servers that move the web pages and various web applications .

One of the most popular distributions in the server world is Ubuntu Server, an official version of Ubuntu that is intended for servers and computers that will be used for this purpose. But, unfortunately, such a distribution does not come with the LAMP server activated, a simple process that we are going to tell you how to do.First we have to say that LAMP stands for Linux Apache MariaDB (MySql) and PHP. So installing a LAMP server is essentially installing all that software and in the same order of the acronyms. Thus, the first thing we have to do is install Apache. We will do this by executing the following command in the terminal:

sudo apt-get install apache2

After installing it, We can check that it works by typing in the web browser the address http: // localhost / and something like the following will appear:

Apache standard page

Now we have to install the database that in this case we will use MariaDB. MariaDB is a fork of MySql so it works anyway but it's free while MySql belongs to Oracle. Installation is also very simple. We have to execute the following commands in the terminal:

sudo apt install mariadb-server mariadb-client

If we have a version prior to Ubuntu 18.04, the most common even for many servers, then we have to execute this before:

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bionic main'

And then we have to execute the following:

sudo apt-get update
sudo apt-get install mariadb-server

We do this with all versions prior to Ubuntu 18.04 because they have an old version of MariaDB while Ubuntu 18.04 has a current version and running the above lines involves installing a modern version of MariaDB.

Now that we have the database we have to continue with the PHP language. In this case we have to execute the following command:

sudo apt-get install php libapache2-mod-php php-mysql

And after this we will have the LAMP server ready and working. But only in a basic way. If we want to install it on a production server we have to take into account the firewall and the modules. This is, In the Firewall we have to open ports 80 and 443.  And if we want advanced PHP functions, then we have to install modules. But that will depend on the needs of each one. In any case, with this we can have a basic and homemade LAMP server that can be used for domestic use.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

2 comments, leave yours

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Bernardo S. Gtz said

    I followed the steps to install lamp in linuxmint 19, and added the code sudo apt-get install phpmyadmin but when entering localhost / phpmyadmin I can't, because I don't have access. How can I enter?

  2.   ice said

    Yes. I also made a video and the more precise configuration steps.