LAMP is a popular open-source web development stack consisting of Linux, Apache, MySQL or MariaDB, and PHP. This guide explains how to install a LAMP stack on Debian 11.
Prerequisites
- Deploy a Debian 11 cloud server at Rcs.
- Update the server.
- Create a non-root user with sudo privileges.
- Log in to your server as the non-root user.
1. Install Apache
Install Apache and related utilities.
$ sudo apt install apache2 apache2-utils -yEnable the Apache service to start at system boot.
$ sudo systemctl enable apache2Start the Apache service.
$ sudo systemctl start apache2Check the status of the Apache service.
$ sudo systemctl status apache22. Install MariaDB
Install the database server.
$ sudo apt-get install mariadb-server -yStart the MariaDB service and enable it to start at system boot.
$ sudo systemctl enable mariadb
$ sudo systemctl start mariadbCheck the status of the MariaDB service.
$ sudo systemctl status mariadbSecure the database with the mysql_secure_installation script and answer Y to all questions.
$ sudo mysql_secure_installation3. Install PHP
Install PHP and common extensions.
$ sudo apt install php php-cli php-mysql libapache2-mod-php php-gd php-xml php-curl php-common -y4. Configure the Firewall
Allow SSH, HTTP, and HTTPS in the firewall.
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow ssh
$ sudo ufw allow 80/tcp
$ sudo ufw allow 443/tcp
$ sudo ufw enable
$ sudo ufw reloadSee our UFW Quickstart Guide for more information.
5. Test the LAMP Stack
Create a test PHP file in Apache's document root folder.
$ echo "<?php phpinfo(); ?>" > /var/www/html/info.phpOpen the location in your browser. Replace example.com with your server's IP address or domain name.
https://example.com/info.phpYou should see a PHP information page with details about your configuration.
More Information
- Learn about Rcs's One-Click LAMP server.