How to install LAMP (Linux, Apache, MySQL & PHP) and PhpMyAdmin on Debian 8

In this tutorial, we will show you how to install LAMP (Linux, Apache, MySQL and PHP-FPM) on Debian 8. The LAMP stack is synonymous with LAMP server or LAMP webserver. It includes Linux, Apache, MySQL (MariaDB), and PHP.

Update the system

Make sure your server is completely up to date with:

apt-get update && apt-get upgrade

Installing Apache

To install Apache on your Debian 8 server, you need to run the following command:

apt-get install apache2

After the installation is complete, you must enable Apache to start at boot:

systemctl enable apache2

Make sure Apache is running by opening a web browser and visiting your server IP (http: // server_ip) You should get the Apache welcome page as shown below:

Installing MYSQL

Now let’s install MySQL. Release the following:

apt-get install mysql-server mysql-client

During installation, you will be prompted for the password for the MySQL root user. Do not enter a password that is easy to crack. It must be at least 8 characters mixed with upper and lower case.

Now that MySQL is installed, we recommend that you install MySQL securely with the command:


Enter your root password and answer ‘P’ when you are asked to change the MySQL root password. Below is the entire procedure that you can follow:

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed!  Not critical, keep moving...
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Enabling MySQL to start at boot:

systemctl enable mysql

You can check the status of the MySQL service by running:

systemctl status mysql

Install PHP

Install PHP by running the following command:

apt-get install php5 php5-mysql libapache2-mod-php5

Now, let’s create a simple PHP page test. Build a PHP info page so you can check your PHP version, active modules, etc …

Create a file, let’s call it info.php in the / var / www / html directory:

vim /var/www/html/info.php

Paste the following code into the file:


Restart Apache for the changes to take effect:

systemctl restart apache2

Now open your favorite web browser and go to http: //your_server_ip_address/info.php. You will get a web page similar to the one below:


Installing PhpMyAdmin

Additionally, you must install PhpMyAdmin so that you can manage your databases more easily using PhpMyAdmin’s intuitive GUI.

Enter the following command:

apt-get install phpmyadmin

During the installation process, you will be presented with several windows to configure PhpMyAdmin. You must choose “Yes“When you get to step “Configure database for phpMyAdmin with dbconfig-common” , after which PhpMyAdmin for databases will be installed and configured.

Then enter MySQL root password, “Password of the database’s administrative user”… Then enter your password in “MySQL application password for phpmyadmin”

After this is over, you will be prompted to enter a window where you can select the web server that will be configured to run PhpMyAdmin. Please select apache2 and then select OK

After the installation is complete, you should be able to access PhpMyAdmin by going to your web browser: http: // your_server_ip_address / phpmyadmin… You will be greeted on the page:


You can login using root as the username and password that you used when setting up your MySQL installation.

That’s all. You have successfully installed LAMP and PhpMyAdmin on the server with Debian 8