---
title: "How to Install a LAMP Stack on Debian"
description: "There are a variety of options you have to customize your Cloud VPS. The most popular combination of software used for web servers is commonly know as the LAMP Stack. LAMP is actually an acronym..."
url: https://www.inmotionhosting.com/support/product-guides/cloud-server/how-to-install-a-lamp-stack-on-debian/
date: 2018-04-12
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Cloud Server Hosting"]
type: post
lang: en
---

# How to Install a LAMP Stack on Debian

There are a variety of options you have to customize your Cloud VPS. The most popular combination of software used for web servers is commonly know as the **LAMP Stack**. *LAMP* is actually an acronym consisting of the following softwares (intended to run the web server): **Linux**, **Apache**, **MySQL**, and **PHP**.

Since **Debian** is already installed, the *L* portion (**Linux**) of the **LAMP Stack** is already installed. In this guide, you can learn how to **install Apache, MySQL, and PHP on Debian**, to create a *LAMP Stack on Debian*.

### Before You Begin

**IMPORTANT:** The following guide does not include instructions for installing the **Debian** OS. If you are currently running an alternative OS on a Cloud VPS, then you can easily *re-OS your VPS* using the tool located in your Account Management Panel (AMP). For instructions to complete a re-OS, please refer to our guide “[How to Re-OS Your Cloud VPS in AMP](/support/product-guides/cloud-server/how-to-re-os-your-cloud-vps-in-amp/)“.

**IMPORTANT:** Root access to a Cloud VPS (running Debian) is required in order to complete the steps in this guide.

**NOTE:** It is imperative that your **Debian Linux distribution** is up-to-date. Follow the steps in this section to perform an update *prior to installing the additional software outlined in the following sections*.

1. [SSH into your server](/support/server/ssh/how-to-login-ssh/) as the **root** user.
2. Run the following command:apt-get update && apt-get upgrade
3. You will be prompted to install the packages found, simply, type ‘y‘ and then hit **Enter**.

That’s it! Just wait for the command prompt to return, indicating that the updates were completed. Now, you are prepared with the **latest Debian version** to begin installing the software described in the following sections.

## Install Apache

**Apache** is the *HTTP* daemon (application) that handles serving the website(s) you create. For more information about *Apache*, you can review the [documentation](https://httpd.apache.org/docs/).

Similar to how you would install *Apache* on other Linux distros, you can simply run a command to accomplish this. In this section, you can learn the command used to *install Apache on Debian*.

1. SSH into your server as the **root** user.
2. Run the following command:apt-get install apache2 apache2-doc
3. You will be prompted to install the packages found, simply, type ‘y‘ and then hit **Enter**.

## Install MySQL

**MySQL** is the database management system that most websites (like WordPress, Drupal, Joomla!) require for advanced functionalies. For more information about MySQL, you can review the Dev.MySQL.com documentation.

*MySQL* is installed in the same manner as *Apache*. Simply run the command specific to **Debian**. In this section, you can learn the process to *install MySQL on Debian*.

1.
   1. SSH into your server as the **root** user.
   2. Run the following command:apt-get install mysql-server php5-mysql
   3. You will be prompted to install the packages found, simply, type ‘y‘ and then hit **Enter**.

**IMPORTANT:** During the installation of *MySQL*, you will be prompted to change the *MySQL root user* password. This is a separate *root user* that is strictly used for *MySQL*. It is strongly recommended that you **reset the default MySQL root password** during the installation and to use a secure password!

**IMPORTANT:** In order to securely setup *MySQL*, you should run the interactive script (as root) by following the steps below.

1.
   1. Run the following command:mysql_secure_installation
   2. When prompted Change the root password? [Y/n], type ‘n‘ and then hit **Enter**, to skip this since the password was already reset during installation.
   3. When prompted Remove anonymous users? [Y/n], type ‘y‘ and then hit **Enter**.
   4. When prompted Disallow root login remotely? [Y/n], type ‘y‘ and hit **Enter**, unless your applications require remote login by the **MySQL root user**.
   5. When prompted Remove test database and access to it? [Y/n], type ‘y‘ and hit **Enter**.
   6. When prompted Reload privilege tables now? [Y/n], type ‘y‘ and hit **Enter**.

Upon successful configuration, the script will display the following message:

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

## Install PHP

**PHP** is one of the scripting languages that can be used by *Apache* to run the scripts that render your website(s). For more information about PHP, you can review official PHP.net documentation.

*PHP* is simply installed using a specific (to the OS) command. In this section, you can learn the command used to *install PHP on Debian*.

1. SSH into your server as the **root** user.
2. Run the following command to *run the installation script for PHP*:apt-get install php5-common libapache2-mod-php5 php5-cli
3. You will be prompted to install the packages found, simply, type ‘y‘ and then hit **Enter**.
4. Once the installation completes, you should restart Apache, for the PHP configuration to be included immediately. To do this, run the following command:service apache2 restart

**Congratulations!** If you have followed this entire guide, then you have just **installed the necessary applications to complete a LAMP Stack**. Now, it is recommended that you test each application, to ensure full functionality of your *LAMP Stack*.

Learn more from our [Cloud Server Hosting Product Guide](https://www.inmotionhosting.com/support/product-guides/cloud-server/).

Experience full control over your server environment and deploy the best operating and management systems that fit your needs with our reliable [Cloud VPS Hosting](https://www.inmotionhosting.com/cloud-vps)!
