BikeGremlin search...
Start » Linux » Installations » LAMP stack install on Linux Mint 19

LAMP stack install on Linux Mint 19

In this article I’ll give short instructions on how to install LAMP stack on Linux (in this case Linux Mint version 19.2). With a short explanation of what LAMP stack is. Separate post explains how to create a database using PhpMyAdmin and add user privileges. For Windows see the post: How to install WAMP.


  1. What is LAMP?
  2. How to install LAMP to a Linux computer
    2.1. Linux update
    2.2. Installing LAMP server
    2.3. Setting up MySQL root password
    2.4. Installing phpMyAdmin
  3. Installing PHP extensions
  4. (File) Paths explained
  5. Other options (Flywheel, Softaculous)

1. What is LAMP?

LAMP is, to oversimplify it, an acronym for Linux Apache MySQL PHP. It is an environment for developing and deploying web applications and websites. Each component is Free Open Source Software (FOSS).

  • Linux is the operating system on which it all runs.
  • Apache is the web server (though NginX can also be used instead).
  • MySQL (or MariaDB) is the relational database management system.
  • PHP (or Python, Perl) is the language for running scripts.
LAMP stack diagram
LAMP stack diagram
Picture 1

This is the basic principle on which all the websites work. Understanding this environment and the relations within it helps solving any potential problems. However, in this post I won’t be going into details on LAMP itself, but focus on showing how to install it on a Linux computer.

2. How to install LAMP to a Linux computer

Simple, step by step, with minimum explanations:

2.1. Linux update

Open the terminal (CTRL + ALT + T) and first update Linux:

sudo apt-get update
sudo apt-get upgrade

Code can be copied (line by line) and pasted into the terminal (CTRL + ALT + V for paste).

2.2. Installing LAMP server

Next step is installing LAMP server:

sudo apt-get install lamp-server^

” ^ ” at the end is not a typing error, it should be included.

Say "Y" to LAMP :)
Say “Y” to LAMP 🙂
Picture 2

Check if Apache is working, by typing “localhost” to in your browser:

If you get the Apache2 page, it's all good (so far)
If you get the Apache2 page, it’s all good (so far)
Picture 3

2.3. Setting up MySQL root password

In terminal type:

sudo mysql -u root

After this command, you’ll be in the mysql> prompt, where you should enter the following:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

Replace “new-password” with a strong password you will memorize. If all went well, you’ll see:
“Query OK, 0 rows affected (0.00 sec)”.

Then exit mysql prompt by typing:


Now restart mysql using the command:

sudo service mysql restart

2.4. Installing phpMyAdmin

Terminal again:

sudo apt-get install phpmyadmin

Look at the pictures 4 and 5 – that is how phpMyAdmin is set up to work with Apache2 server.

If "apache2" is not selected, select it (using up/down keyboard arrows) and hit Enter
If “apache2” is not selected, select it (using up/down keyboard arrows), press space to mark it with an asterisk (SEE PICTURE 5).
Picture 4
After the asterisk was set (using space bar), press Enter
After the asterisk was set (using space bar), press Enter
Picture 5
Leave the default ("Yes") and hit Enter, unless you have a good reason to do otherwise
Leave the default (“Yes”) and hit Enter, unless you have a good reason to do otherwise
Picture 6
Enter a password for phpMyAdmin to connect to the database, hit Enter - then you will be asked to re-enter the password to confirm it
Enter a password for phpMyAdmin to connect to the database, hit Enter – then you will be asked to re-enter the password to confirm it
Picture 7

Check if it works, typing this in your browser:


You should get something like this (logging in with “phpmyadmin” username and the password set in picture 7):

phpMyAdmin working, login screen
phpMyAdmin working, login screen
Picture 8

In case it doesn’t work (404 error), try the following commands in terminal:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2

3. Installing PHP extensions

PHP extensions are compiled libraries that allow various functionalities. To see the version, setup and the installed extensions of the PHP, do the following:

Open a text editor, copy paste the following code and save it as “phpinfo.php”:

<?php phpinfo(); ?>

Now that file needs to be copied to directory:

You can’t copy to this directory without root access. So open terminal and type:

sudo nemo

This will start the Nemo file manager with root privileges. Allowing you to copy/paste the file. After copying, type in your browser:


Looking at the extensions list, I noticed that imagick I use is missing. It is installed with the following command in terminal:

 apt install php-imagick -y

Now just restart the Apache2 server:

sudo service apache2 restart

What’s left now is to create a database in PhpMyAdmin and start making websites.

And that’s it. Faster than you could say “Supercalifragilisticexpialidocious!” 🙂

4. (File) Paths explained

Thanks to this question/feedback, I’m adding the info to this article – in case it helps anyone else.

When you try to open http://localhost/, your MAMP server will look for an “index.htm“, “index.html”, or “index.php” files on this path:

If you wish to run some other, particular file, say “phpinfo.php”, stored as  /var/www/html/phpinfo.php, your browser address should be:

Same goes for files, or website installations placed in a subdirectory. Say we install WordPress in a subdirectory named “wordpress-test01”, its path being: /var/www/html/wordpress-test01/. Running the installation (or the website itself, after having run the famous “5-minute installation”) would be done by visiting the following address from our browser:

5. Other options (Flywheel, Softaculous)

Sometimes, for whatever reason, installing MAMP is not the most practical solution. Other, rather practical (and free) alternatives are the following:

  • Local by Flywheel – run on your computer
  • Softaculous – run on a (shared) hosting server

There are countless other options as well, but these are the one’s I’ve “played with” the most and the ones I find the most practical. I wrote about these in separate articles:

14 thoughts on “LAMP stack install on Linux Mint 19”

  1. Thanx for this. It is the only set of instructions out of several that finally worked for me. Kudos!

    • Thanks. Found the setup that worked for me, then tested on a few different desktops and laptops, then put it here for future reminder/reference. 🙂

  2. my myphpadmin asks for password but I cant remember setting a password for it and I cannot even login, please help

  3. Help please! I’m mid 50’s studying a web dev course online while furloughed trying to guard against the worst. Everything’s new and every day I’m out of my depth but this php section of the course has me ready to just quit.

    I got MAMP installed on the windows laptop ok but trying to install an equivalent on the linux laptop has me doubting everything. This page is the nearest I’ve got to success. It’s the clearest most succinct guide I’ve found. But I’m stuck.

    I copied pasted and saved as it’s own file but i’m unsure this being all new, so to clarify: /var/www/html/ means save it in the html folder or create a folder at the html level to keep the file in-thus creating another level below the html folder? So it becomes /var/www/html/php?

    I did go through the process having pasted the file into the html folder but then http://localhost/phpinfo.php just returned a 404 server not found message. Is this something I can do through online at the phpmyadmin page? Linux and working in the terminal is new too.

    Sorry for rambling and for the long message, hope this makes sense.

    • Path would be:
      or however the .php file is named (can be test.php)

      shows whatever is inisde the /var/www/html/
      If you have an index.htm, or index.php, saved there, those two will automatically be run, and shown when you type, in your browser:

      If you wish some other, particular file, it must be correctly named.
      For example, if phpinfo.php is stored in /var/www/html/ – then typing http://loalchost/phpinfo.php will “run” it.

      Also, one can make a subdirectory, and place the file there. Say we make a test subdirectory:
      Place test.php there:

      “Running” it from the browser would be:

      Solomon solution would be installing Local by Flywheel. 🙂
      It is simple and works, as far as WordPress goes, which most people use nowadays.

      My article on that, from a local WordPress workshop:

  4. Hi Relja, thank you so much especially for such a quick response. This has helped me out of a hole today and I’m very grateful to you for that. I have the link working (links/paths were a big hurdle for me in the html part of the course) and your reply will be a useful reference going forward too.

    There seems so much to take in with such a steep learning curve just now but you’ve helped me to get back on the bike and start pedalling again.

    Thanks again, Jim. 🙂

    • Suppose that learning curve depends on the starting level of knowledge.
      It also depends on how one is taught. Pinpointing the proper way for each individual student is not easy, but if it can be done (individual lessons, or small groups of similar knowledge-level students), it makes things a lot faster and easier for both the students and the teacher.

      WordPress has made things so easy and simple that I’ve seen some people who make a living of website development be clueless about how it all works. Installing LAMP (using Linux)?! No – just take Local by Flyweel and work on… 🙂 Customers are happy, they are happy – suppose hosting tech. support does get bothered a bit more than necessary, but who cares… 🙂

      Taking the time to learn the basics does help, in my opinion – allowing one to be more independant and solve more problems on their own. But one should consider how deep to go into everything, since it’s both very broad, and very deep – no one can learn everything even in two lifetimes.

  5. The starting level was slightly above nothing at all, but I want to try and persevere. The course so far has been very good, the guy hosting it is nearer my own age and has a reassuring style and also says the same as you’ve just said-that it’s so broad and deep no-one can know it all.

    I know the course will give me a good overview of things with a possible entry point into several different directions, and I like that idea of not feeling a stranger whichever path I choose even if I’m no expert. It’s offers the confidence to know you can learn more.

    I’m going to read a little bit more about Local by Flywheel to see what it is-I googled it just now to get a basic definition. I think the HTML/CSS/JS might have given me a false sense of security and now with PHP it gets serious. However it goes I’ll let you know when I’m on the other side, thanks again 🙂

  6. I’ve looked at a number of LAMP install on Linux pages and, IMHO, this is far and away the best. Thanks very much.
    The only (slight, rather insignificant) variation I made was to call “sudo nano” in the terminal, paste in “” and then save the file to “/var/www/html/phpinfo.php”.
    I’m now off to follow the link “create database in PhpMyAdmin”
    best regards 🙂


Leave a Comment