LAMP (Linux, Apache, MySQL and PHP) is critical for developers who require this combination of open source software for developments on their local machines before publishing their websites. In this package, Apache is the web-server, MySQL for database management while PHP is the programming language. In this tutorial we are going to see how to install LAMP on Elementary OS 5.

Update your system repository

Before installing LAMP server, first update and upgrade your apt by running the below commands on your command line:

sudo apt-get update -y
sudo apt-get upgrade -y

Installing LAMP server on Elementary OS 5

sudo apt-get install -y lamp-server^

Do not forget to include the caret (^) at the end must of the command

Test Apache web server

Check if Apache properly installed and is running

sudo systemctl status apache2

If properly installed and running, the output should be as below:

On your browser, type http://localhost. This should display the default Apache2 page.

Test your PHP installation.

PHP is the programming language packaged in LAMP stack. To check whether is it properly installed, write a simple PHP script that displays PHP information.

sudo vim /var/www/html/info.php

Paste the below content and save the file.

<?php phpinfo(); ?>

Restart Apache2 service

sudo systemctl restart apache2

Now go to your browser and type http://localhost/info.php. A successful installation displays a page with PHP information as shown below.

Set MySQL root password

The previous installations would prompt to set MySQL root password but with the current installation, root password is set from the terminal. On your terminal, login to MySQL using the command below:

sudo mysql -u root

Set root password for MySQL using the below command, replacing ‘mypassword’ with one of your choice.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword' ;

Restart mysql

sudo systemctl restart mysql

Install phpMyAdmin on Elementary OS 5 Linux

Using MySQL command line is a great tool for those who have a good knowledge of MySQL commands. PhpMyAdmin, however, provides a friendly graphical interface for managing databases. PhpmyAdmin is not part of LAMP stack but it has been greatly used to simplify MySQL database management.

sudo apt install -y phpmyadmin

When prompted to choose the web server, press spacebar to select apache2 and an asterisk will appear next to it. Press tab to go to ok then press Enter. In the next dialogue box, press Enter to choose Ok and you will be prompted with another dialogue box. Go with Yes which is chosen by default and press Enter

You will then be prompted to enter phpMyAdmin password. Enter the password that you selected before for mysql and press tab then Enter.

Next, you will be prompted to confirm the password. Repeat the password as above then press tab and Enter.

How to access PhpMyAdmin

On your browser, enter /localhost/phpmyadmin and you will be prompted with phpmyadmin login page.

Type your username and password for phpmyadmin and click on GO button to log in.

Phpmyadmin will also be added to your system application where you easily access it from.

You have successfully installed LAMP stack on Elementary OS 5. Check other guides that we have below:


Please enter your comment!
Please enter your name here