LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Sunday, June 14, 2020

Install LAMP on Debian/Ubuntu

0 comments
A LAMP Stack is a set of open-source software that can be used to create websites and web applications. LAMP is an acronym, and these stacks typically consist of the Linux operating system, the Apache HTTP Server, the MySQL relational database management system, and the PHP programming language.

Apache Web Server

Apache web server is an HTTP server of the Apache Foundation. It is the most popular in the world for its ease of use and configuration, because it has extensive community support and for being installable on many Linux systems.

On the other hand, the Apache webserver stands out for its large number of modules that make it perfectly configurable. It is also quite robust and secure.

To install it, open a terminal emulator or connect to your Debian 10 system using SSH. Then, access as the root user and run.

sudo su
sudo apt install apache2

Once the installation is complete. Debian/Ubuntu will automatically start the service and enable it to boot along with the system. However, you can start and stop it manually with these commands:

sudo systemctl start apache2
sudo systemctl stop apache2

If you don’t want to start the system, use this command:

sudo systemctl disable apache2

But, if you want to enable again:

sudo systemctl enable apache2

If you want to see the status od apache2

sudo systemctl status apache2

After that, open your favorite web browser, and in the address bar access your server. Either by localhost/remote server IP address or by domain. You should see the following.

1.- Apache default page on Debian
So, Apache is running.

Until now, the Debian/Ubuntu system will only be able to run client-side websites, i.e. front end technology. However, we know that web applications use something else. Mainly, they use a programming language on the server that can run the application.

In the same way, PHP is the most popular web-oriented programming language in the world. Many of the world’s most powerful applications, e.g. WordPress the most widely used CMS, are made in PHP. And so many others. That is why, on a Web server, it has to be PHP.

Open a terminal and run the following command to install PHP and Extensions:

sudo apt install php libapache2-mod-php php-mysql php-mbstring php-xml php-zip

After that, it is a good idea to test PHP. So, create a new file on /var/www/html/ called test.php and add the following. For example, you can use nano.

sudo nano /var/www/html/test.php

<?php
phpinfo();
?>

Then, restart Apache.

sudo systemctl restart apache2

Now, open the file using the web browser. For example, http://your-server/test.php You will see this:

2.- PHP running on Debian/Ubuntu

So, Apache and PHP are running.

Install MariaDB

The last component we need to get to install LAMP on Debian/Ubuntu is MariaDB or MySQL. MariaDB is a MySQL fork. It is a great relational SQL database manager with fairly broad community support.

MariaDB combines usability with security and all under the protection of the community and large distributions such as CentOS, Debian, Ubuntu, and RHEL.

Open a terminal and run this command to install it:

sudo apt install mariadb-server

Then, it is necessary to secure the installation using the mysql_secure_installation script. Using that script, you will be able to define a root password and other basic settings.

sudo mysql_secure_installation

This will take you through a series of prompts where you can make some changes to your MariaDB/MySQL installation’s security options. The first prompt will ask whether you’d like to set up the Validate Password Plugin, which can be used to test the strength of your MariaDB/MySQL password. Regardless of your choice, the next prompt will be to set a password for the MariaDB/MySQL root user. Enter and then confirm a secure password of your choice.

From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MariaDB/MySQL immediately respects the changes you have made.

No comments:

Post a Comment