LAMP Stack Linux Mint Installation

How to install a LAMP stack on Linux Mint 19 and Linux Mint 19.1 for local web development. A local LAMP stack (Linux, Apache, MySQL and PHP) with phpMyAdmin is necessary for web development and testing locally before making a web site live. This tutorial should be of interest to anyone wanting to do PHP and MySQL development on a Linux computer. It also applies to WordPress development as WordPress uses PHP and MySQL.

Updated LAMP Stack Linux Mint Installation Tutorial

Some things have changed in the installation steps of a LAMP stack on Linux Mint 19 and higher since the older blog post on how to install a LAMP stack on Linux, which worked on Linux Mint versions before 19 (versions 18 to 18.3). This tutorial shows the steps on how to install a LAMP stack on Linux Mint 19 and 19.1. It should also work on other newer Linux Mint versions when they are released and on other similar Linux distributions such as Ubuntu.

LAMP Stack Linux Mint Installation Steps

Installation is very similar to the previous tutorial, however some steps have changed for Linux Mint 19+. Rather than editing the previous tutorial and trying to mix the new steps in, all steps are included in this new tutorial, starting below.

Update Linux

Open a terminal window (shortcut Ctrl + Alt + t) and do an update before installing the LAMP server.

sudo apt-get update

And then:

sudo apt-get upgrade

Install the LAMP Server

To install the LAMP server enter the following in the terminal window.

sudo apt-get install lamp-server^

Important: The caret (^) at the end of the above line is not a typo and must be included in the command. (Reference and how to remove the LAMP stack.)

After entering the above command, a list of changes that will be made is displayed in the terminal window. At the bottom of the list you will be prompted whether to continue or not.

0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
 Need to get 26.1 MB of archives.
 After this operation, 184 MB of additional disk space will be used.
 Do you want to continue? [Y/n]

Hit Enter to continue with the installation.

LAMP Stack Linux Mint Apache Test

Now that the LAMP stack is installed on Linux Mint, the Apache web server can be tested.

The default Apache web server page of the local LAMP stack should display after entering localhost in the address bar of a web browser as shown below.

LAMP Stack Linux Mint - Testing the Local Apache Server
LAMP Stack Linux Mint – Testing the Local Apache Server

This web page can be found at /var/www/html in the file system of the host machine. If the index.html file is edited or replaced here, the new page will be found at localhost in a web browser.

Set the MySQL Root Password

The installation no longer prompts to set the MySQL root user password. Without this password it is not possible to log in to phpMyAdmin. The password is set from the command line and can be done from the terminal window that was opened for the LAMP installation.

Log in to MySQL from a terminal window as follows.

sudo mysql -u root

Important: You must start MySQL with sudo, after which you will be prompted for your Linux login password which will give MySQL administrator privileges in order to set its root password.

After entering the above command, you will arrive at the mysql> prompt as can be seen in the image below.

LAMP Stack Linux Mint Installation - Logging into MySQL
LAMP Stack Linux Mint Installation – Logging into MySQL

Now enter the following MySQL command, but replace new-password with the password that you want to use for root and for phpMyAdmin login. Be sure to type all of the characters in the line below, or rather copy it and then modify the password before pasting at the mysql> prompt.

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


If the command is accepted, MySQL will display the following message in the terminal window.

Query OK, 0 rows affected (0.00 sec)

Exit from MySQL by typing quit at the mysql> prompt:


Now restart MySQL by entering the following command in the terminal window.

sudo service mysql restart

Install phpMyAdmin

To install phpMyAdmin, enter the following in a terminal window.

sudo apt-get install phpmyadmin

A list of packages that will be installed is displayed followed by a prompt to continue.

Need to get 5,843 kB of archives.
 After this operation, 33.3 MB of additional disk space will be used.
 Do you want to continue? [Y/n]

Hit Enter to continue with the installation. You will be prompted to choose the web server that will be configured to run phpMyAdmin. Choose apache2 by pressing the space bar.

Configuring phpMyAdmin Web Server Dialog Box
Configuring phpMyAdmin Web Server

After pressing the space bar, an asterisk will appear next to apache2 as shown below. Hit the Enter key to continue.

Select apache2 in the Dialog Box
Select apache2 by Pressing the Space Bar

Installation will continue and then pop up another dialog box. In this dialog box, hit Enter to select the default of Yes.

Configuring phpMyAdmin Dialog Box
Configuring phpMyAdmin Dialog Box

You will now be prompted for a password for phpMyAdmin. Type a password and then hit Enter.

phpMyAdmin Password
phpMyAdmin Password

Confirm the password by entering it in the next dialog box.

phpMyAdmin Password Confirm
phpMyAdmin Password Confirm

The installation will continue and then complete.

Accessing phpMyAdmin

In Linux Mint MATE phpMyAdmin can be accessed from the menu button found on the bottom task bar or panel as follows:
Menu → Programming → phpMyAdmin.

Alternatively enter localhost/phpmyadmin/ in the address bar of a web browser.

Use a user name of root and the password that you set when changing the MySQL root password. The following image shows the phpMyAdmin login page.

Logging in to phpMyAdmin
Logging in to phpMyAdmin

Configuring the Local LAMP Stack

A tutorial on configuring the LAMP stack on Linux Mint 19+ shows how to set up Apache to host multiple local websites for use in web development.

Linux Mint Version

This tutorial was tested on Linux Mint 19.1 MATE 64-bit and Linux Mint Cinnamon 19.1 64-bit.

23 thoughts on “LAMP Stack Linux Mint Installation”

  1. Hi all worked fine up to Accessing phpmyAdmin and this is where I am stuck as all I get when I type http://localhost/myphpadmin is a 404 File not found error , when I try I get the same error.
    Could you please advise of a fix so I can then move onto setting up wordpress and please keep it simple as I am fairly new to Linux.
    I am using Linux Mint Mate Tara.
    As I would like to test the porting of my html Website into wordpress to see it all works, with the vision of up dating my online site as well.
    Thanks in Advance,

  2. After setting the phpmyadmin password I tried to login but it says

    #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)


    mysqli_real_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES)

    I’m using Mint 19.3 Cinnamon

    1. Hi Sean,

      Seems you also fallen into the same mistake, when you also did not replaced the “new-password” with something else at this stage:
      ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘new-password’;

      Just try to log in as root and type the password simply: new-password. Most likely will works, like works to me 🙂

    2. I have the same issue.
      I used login root, and my password is phpmyadmin…
      Is the password maybe too weak?

  3. I went through all steps, all was fine, but I also get
    => 404 error, not found
    I also don’t have a Programming Menu and neither phpmyadmin.
    I am using Linux Mint 19.3 Cinnemon.
    I also ran the command Victor, unfortunately without luck.

  4. This is a really nice tutorial. It worked straight out of the box.

    I was wondering.. Is there also an easy way of setting up a lamp stack with docker? Just one line on a commandline and everything is set up? Without installing and changing things on your system?

  5. Thanks for this. I made the mistake of hitting ENTER too soon at the stage of choosing which server to reconfigure automatically. I should have hit the SPACEBAR first. Consequently I had no phpmyadmin in the menu and localhost/phpmyadmin got a 404 error.
    Victor Leonardo’s post above gave me the solution:
    Open the terminal, type:
    sudo gedit /etc/apache2/apache2.conf
    and below the end of file, at the last line, type
    include /etc/phpmyadmin/apache.conf

    I then restarted apache with:
    sudo service apache2 restart

    and now it works fine.

  6. I can confirm that this tutorial works flawlessly on Linux Mint 20 “Ulyana” – Cinnamon (64-bit)
    The installation of MINT is vanilla i.e. no packages loaded apart from updates.
    @CodeNerd I have only been using Mint for 6 months and used this tutorial for 19.3 earlier – had I not come across this I probably would have loaded each LAMP (AMP) component individually. Thank you so much for taking the effort to produce this. Probably saved me hours 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *