How to install LAMP on Ubuntu 18.04 LTS?

0
108
Image from pixabay
Image from pixabay

One of the most basic functions of a server is to provide network services. Besides this, it is the base where many applications have installed either desktop or web. The latter is becoming more and more popular due to the simplicity of installation, deployment, maintenance, and accessibility. That’s why many companies bet that their main applications are with a web interface that can even be accessed from a mobile. So a server without HTTP access service is practically very scarce these days. So, in this post, I will show you how to install LAMP in Ubuntu 18.04.

LAMP is one of the most common software stacks within Linux. Thanks to it, we can have a fully functional HTTP server, capable of running various applications. It is the acronym for Linux, Apache, MariaDB, and PHP.

The first characteristic of LAMP is that it allows us to have a web server for dynamic websites. These dynamic websites, also make references to applications with web interface. So installing LAMP is essential for our Linux server to be functional.

On the other hand, many web servers use Ubuntu 18.04 as a base because it is a special distribution for servers. In the same way, the components of LAMP are available quickly and easily in this and other Linux distributions.

It is also good to note that, its low cost of implementation, in resources and money, make it very popular throughout the cloud.

So, let us start.

Install LAMP on Ubuntu 18.04

1) L – Linux

The first component of the LAMP is Linux. Obvious, but we want to emphasize that LAMP can be installed in many Linux distributions such as OpenSUSE or CentOS.

In the case of Ubuntu, we did a tutorial about how to install Ubuntu 18.04.

You can read: How to Install Ubuntu 18.04 LTS.

Once you have completed it, you will have the first step of our tutorial.

2) A – Apache web server

Apache is a web server of the Apache Foundation. He is a veteran in this segment since its development started a long time ago.

It is also one of the most used worldwide and is quite customizable. It also has powerful documentation that makes it quite flexible along with its modules.

So let’s install it.

To do this, open a terminal and run:

:~$ sudo apt install apache2
1.- Install LAMP - Install Apache web server
1.- Install LAMP on Ubuntu – Install Apache web server

By default, Ubuntu will start the Apache service once the installation is complete. It will also start during system loading. To check that everything went well, we can open the web browser and access the server by placing the server’s IP address in the address bar. For example, http://SERVER_IP/

2.- Apache default page
2.- Apache default page

That’s the default Apache page, so the installation was successful.

3) M – MariaDB

Dynamic web pages usually need to store data. So it is necessary to have a database manager. There are many good ones, but the next component of the LAMP is MariaDB.

MariaDB is a MySQL fork. Therefore, we are talking about a database manager, open source, robust, reliable and the best, perfectly compatible with MySQL.

To install it, just run the following command:

:~$ sudo apt install mariadb-server
3.- Install MariaDB
3.- Install MariaDB

As with Apache, the system will start the service immediately. After that, it is necessary to use the MariaDB configuration script to define the root password and other things.

:~$ sudo mysql_secure_installation
4.- Set the root password for MariaDB
4.- Set the root password for MariaDB

After defining the root password, we will be asked other configuration questions. Take into account each of them, they are important and fit your needs. So when you read them, answer what you consider appropriate.

Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n] 
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

Once you have completed answering the questions, MariaDB is ready to begin the work.

4) P – PHP

If we are talking about web applications, we have to mention PHP. PHP is the most popular programming language for web application development. Many professional applications use it so it is a very good language.

PHP is constantly evolving with a fairly active pace of development and where every time much is improved. Fortunately, the version that includes Ubuntu 18.04 is a quite mature and novel version as is 7.2.

On the other hand, it is necessary to install some PHP modules to work with Apache and MariaDB.

:~$ sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-curl php7.2-mbstring php7.2-xmlrpc php7.2-mysql
5.- Install PHP
5.- Install PHP

How to install new modules for PHP. It is necessary to restart Apache for it to work.

:~$ sudo systemctl restart apache2

Then, you have to test that PHP is working correctly, to do this, create a file in /var/www/html/ called test.php and add the following:

:~$ sudo nano /var/www/html/test.php
<?php
phpinfo();
?>
6.- PHP test
6.- PHP test

Nex, open it using the web browser. You will see this.

7.- PHP info
7.- PHP info

So,  PHP is working

Conclusion

So now you know how to install LAMP in Ubuntu 18.04 and with this, you can have a home web server. This way you can develop and run web applications on a server.

Please share this post with your friends.

LEAVE A REPLY

Please enter your comment!
Please enter your name here