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.
Open a terminal window (shortcut Ctrl + Alt + t) and do an update before installing the LAMP server.
sudo apt-get update
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.
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.
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
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.
After pressing the space bar, an asterisk will appear next to apache2 as shown below. Hit the Enter key to continue.
Installation will continue and then pop up another dialog box. In this dialog box, hit Enter to select the default of Yes.
You will now be prompted for a password for phpMyAdmin. Type a password and then hit Enter.
Confirm the password by entering it in the next dialog box.
The installation will continue and then complete.
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.
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.