Installing LAMP Stack (Linux Apache, MySQL, phpMyAdmin and PHP) on Linux Mint

Installing Apache2, MySQL and PHP 7 on Linux Mint 20 + solving PHP code shows on the page but not executed

Nabilla Mahmud
Apr 11 · 4 min read

This tutorial explains how to install LAMP (Linux Apache, MySQL and PHP) in Linux Operating System especially for Linux Mint Distro. As we know that Apache2 is a web server, MySQL is for database and PHP is processing/programming language for making a web page. I currently use PHP7.4 (latest version of PHP 7 currently in April) because i think it still familiar to use rather than the newer, PHP 8.

Photo by Ben on Unsplash

Update All Your Packages on Linux

Before we install LAMP stack, make sure you have update and upgrade your Linux Package Database. First open up your Linux Terminal (Applications > Accessories > Terminal), type these command and press Enter in terminal:

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

Terminal then will ask you for password. Type your Linux User password and press enter.

Install Apache2 (Web Server)

After your packages database is updated and upgraded, type this to install Apache2:

sudo apt-get install apache2 -y

To check if it already installed type in the command below in terminal and press enter:

apache2 -v

and you will get something like this in terminal.

To ensure Apache2 works correctly, open any web browser (ex: Google Chrome or Mozilla Firefox) and enter the following into browser web address:


You may see “It Works!” page, congratss 🎉🎉

Installing PHP 7

Open up yout terminal, type or copy/paste the following command:

sudo apt-get install php7 libapache2-mod-php7 -y

then restart Apache2 so PHP will work and compatible to Apache2 web server.

sudo /etc/init.d/apache2 restart

To test and check if PHP works correctly, first make a file named phpinfo.php in /var/www/html directory and write <?php phpinfo(); ?> inside the file or if you like to make it by CLI you can make the file by the following command in terminal:

sudo nano /var/www/html

then copy/paste this code

<?php phpinfo(); ?>

press ctrl+x, y and Enter.

Open up your browser and enter the following:


You should see something like this, and start to code.

I get this issue when i first installing LAMP for the first time in Linux Mint 20. If you get the same issue i give a small tutorial for you. Maybe it will solve your problem (i hope so).

You just need to open up terminal (again) and add some code to apache2.conf inside /etc/apache2 directory. You can do it by command line like:

sudo nano /etc/apache2/apache2.conf

and at the end of file add this code (by typing it or copy/paste it):

<FilesMatch "\.ph(p?|tml)$"> 
SetHandler application/x-httpd-php74

Take a focus on “application/x-httpd-php74” i write it 74 because i use PHP 7.4 version. Make sure you have checked your PHP version by php -v in your terminal before you write the code.

After that, press ctrl+X, Y and Enter. I wish it solved your problem.

Installing MySQL Database by CLI

First open up your terminal, then copy/paste it or type into terminal:

sudo apt-get install mysql-server -y

then run MySQL by:

mysql -u root

You will get something like this, it means your MySQL works correctly.

If you want to set password to root MySQL user, do the following command to terminal:

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. You can call it GUI version of MySQL.

To install it just do this command:

sudo apt-get install libapache2-mod-auth-mysql php7-mysql phpmyadmin -y

Make sure you write php*-mysql based on PHP version you have use.

To get PHP to work with MySQL, you need to uncomment by deleting semicolon (;) at:


and add php_mysqli extension with:

After that press ctrl+X, Y and Enter. Restart Apache and you are all set! 🎉🎉

Open your browser and enter the following to the web address


You will see this.

Configure Apache2 by apache2.conf file:

sudo nano /etc/apache2/apache2.conf

Copy/paste code below at the end of file.

Include /etc/phpmyadmin/apache.conf

Then restart Apache2 Web Server.

sudo /etc/init.d/apache2 restart

Okay, you’re all finally set. Hope it helps you :)


Easy read, easy understanding.

Nabilla Mahmud

Written by

IT Student. Seorang pemikir yang senang menyalurkan pikirannya melalui Medium. Happy reading :)



Easy read, easy understanding. A good writing is a writing that can be understood in easy ways

Nabilla Mahmud

Written by

IT Student. Seorang pemikir yang senang menyalurkan pikirannya melalui Medium. Happy reading :)



Easy read, easy understanding. A good writing is a writing that can be understood in easy ways

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store