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.

Contents:

  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


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:

quit

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:

http://localhost/phpmyadmin/

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:
/var/www/html/

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:

http://localhost/phpinfo.php

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

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

Share...

2 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. 🙂

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.