Search
Close this search box.

How to install LAMP Stack on Debian

Table of Contents

How to install LAMP Stack on Debian

 

Back-end development using LAMP has gained popularity because it is free and open-source. LAMP is comprised of a Linux OS, an Apache web server, a MySQL database, and PHP programming language. It allows developers to easily deploy and customize software. However, it is now more of an interchangeable generic model of the software stack. We will guide you in this article through the process of installing LAMP stack on your Debian system.

 

VPSie also provides LAMP One Click Installation. If you do not already have a VPSie account, you need to create one to register Debian or LAMP systems on the VPSie platform.

 

Instructions on how to use LAMP one-click deployment can be found on the link. If you are going to install manually, you can skip this.

 

 

 

Let’s get started,

 

Step 1: Update your system

 

Run the following command to get the latest package versions and dependencies.

 

 

# sudo apt update
# sudo apt upgrade

 

 

 

Step 2: Install Apache

  

Run the following command to install the Apache:

 

 

# sudo apt install apache2 apache2-utils

 

Now run the following command to enable apache2:

 

# sudo systemctl enable apache2

 

 

 

Check the status of the Apache2 after the installation:

 

 

# sudo systemctl status apache2
Apache2

 

You can also run the following systemctl commands to start, stop, restart  the Apache web server.

 

# sudo systemctl start apache2.service 
# sudo systemctl restart apache2.service 
# sudo systemctl reload apache2.service
# sudo systemctl stop apache2.service

 

 

 

Step 3: Install MariaDB

 

The MariaDB can be installed by running the following command:

 

# sudo apt install mariadb-server mariadb-client

  

After the installation, you should run the security script that follows to remove insecure defaults. To do so run the following command:

 

# sudo mysql_secure_installation

 

It will ask some questions, follow the pictorial representation:

 

 

MariaDB setup
MariaDB setup

 

 

 

Check Now create the Database and grant your users permission, Run the following commands:


# mysql -u root -p

 

CREATE DATABASE lamp_database;
GRANT ALL ON lamp_database.* TO 'test_user'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

 


You can change the DBnamen Username, Password with your option.


DB Setup

 

Step 4: Install PHP

 

On DEB.SURY.ORG, PHP 8 packages are available for Debian. Download and install the dependencies. Run the following commands to do so:

 

 

# sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2

 

 

 

Make sure that your Debian server has the PHP packages APT repository. You can do this by running the following command.

 

 

# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list

 

 

Import repository key:

 

 

# wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

 

 

 

Update the package index after adding the repository:

 

 

# sudo apt update

 

 

 

Now install the PHP 8.0 and its modules using the following command:

 

 

# sudo apt install php8.0 libapache2-mod-php8.0 php8.0-mysql php8.0-curl php8.0-xml php8.0-zip php8.0-mbstring php8.0-intl php8.0-opcache php8.0-imagick php8.0-gd php8.0-cli php8.0-fpm libapache2-mod-fcgid -y
PHP installation





That’s all. Your LAMP stack has successfully been installed on your Debian machine. Thank you for taking the time to read this tutorial.


Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.