• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install LAMP Stack on Debian 9

Written by Admin, Updated On May 7, 2019
apache, debian, lamp, mariadb, php
How To Install LAMP Stack on Debian 9

LAMP stack on Debian 9 is a group of open-source software that is typically installed together to host dynamic websites. LAMP stands for Linux OS, with Apache web server, Data store in a MySql or MariaDB database, and dynamic content is processed by PHP.

Install LAMP Stack on Debian 9#

This tutorial will shows one by one step how to install LAMP stack on Debian 9 server.

Prerequisites#

Firstly, you need Debian 9 server with a non-root sudo enabled user account.

Step 1 – Installing Apache#

Apache web server is most popular web server in the world. It also has a great community support so it’s default choice for hosting a website. Execute following commands to install Apache :

sudo apt update
sudo apt install apache2

Here, we use sudo as command so these operations are executed with root privileges. It will prompt you to enter your regular user password to verify.

On entering correct password, it will show details which packages will be install and how much disk space they will take. Press Y and hit Enter to continue and installation process will started.

After that, Make sure that your firewall allows HTTP and HTTPS traffic. You can check “WWW Full” profile enables traffic or not :

sudo ufw app info "WWW Full"
Output 
Profile: WWW Full
Title: Web Server (HTTP,HTTPS)
Description: Web server (HTTP,HTTPS)

Ports:
80,443/tcp

It should show that it enables traffic to ports 80 and 443 or you can Allow incoming HTTP and HTTPS traffic for this profile:

sudo ufw allow in "WWW Full"

You can test it quickly by visiting your server’s public IP address in your web browser.

http://YOUR_SERVER_IP

It should display a default Debian 9 Apache web page as following screenshot :

Debian 9 Apache Default Page

If it will show this page then your Apache installation is successful.

Step 2 – Installing MariaDB #

MariaDB is a multi-threaded and open-source database management system which will organize and provide access to databases where your site can store information. It is a replacement of MySql and developed by some of the original developers of the MySql.

With the release of Debian 9, MySQL was replaced with MariaDB as the default database system.

Execute following command to install mysql server.

sudo apt install mariadb-server

By default, MariaDB service will start automatically. You can verify it by typing:

sudo systemctl status mariadb

Finally, your MariaDB server is installed and ready to use.

Step 3 – Installing PHP#

PHP component will process code to display dynamic content. Execute below command with helper packages so it can communicate with Apache and can make connection with MariaDB database.

sudo apt install php libapache2-mod-php php-mysql

So PHP installed without any issue and we will check it now. Now, restart Apache web server in order to get your changes by executing below command :

sudo systemctl restart apache2

Step 4 – Testing Setup#

In order to test that your system is configured properly for PHP, create a very basic PHP script called info.php.

So create this file at web root of server. In Debian 9 directory is located at /var/www/html/ so create file here by executing this command :

sudo nano /var/www/html/info.php

Add the following PHP code inside the file:

<?php
phpinfo();
?>

At last, Save and close file. Now visit this page in web browser using your server’s public IP address as following :

http://YOUR_SERVER_IP/info.php

It should show as following screenshot:

How to Install LAMP Stack on Debian 9

Finally, you finished it.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install LEMP Stack on Ubuntu 18.04
Next Article   How to Install LEMP Stack on Debian 9

Related Posts

  • How to Change Hostname Debian 11

    How to Change Hostname on Debian 11

    February 3, 2023
  • How to Install and Use PHP Composer on Ubuntu 22.04

    How to Install Composer on Ubuntu 22.04

    January 31, 2023
  • How to Install Python 3.11 on Debian 11

    How to Install Python on Debian 11

    January 25, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Jenkins on Debian 11
    How to Install Jenkins on Debian 11 January 5, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook