Skip to main content

How To Install Apache, MariaDB, PHP (LAMP Stack) on Debian 11


LAMP Stack stands for Linux, Apache, MariaDB, and PHP stack. This stack is used by most web hosting companies to host websites, blogs and is also used in web developments. Due to free and open-source licensing, this stack is the best alternative to expensive stacks.

Install LAMP Stack

Install Linux

Follow the Step by Step installation of Debian 11 or Upgrade Debian 10 "Buster" to Debian 11 "Bullseye".

Now, we will proceed to install Apache v2.4.48, PHP v7.4, MariaDB v10.5 on Debian 11.

Install Apache

First, we will start with installing the Apache webserver.
sudo apt update sudo apt install -y apache2 apache2-utils

Check the status of the Apache server service post the installation.
sudo systemctl status apache2

Output:
● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-08-24 09:20:01 CDT; 33s ago Docs: https://httpd.apache.org/docs/2.4/ Main PID: 1930 (apache2) Tasks: 55 (limit: 2321) Memory: 10.8M CPU: 58ms CGroup: /system.slice/apache2.service ├─1930 /usr/sbin/apache2 -k start ├─1932 /usr/sbin/apache2 -k start └─1933 /usr/sbin/apache2 -k start Aug 24 09:20:01 debian11.itzgeek.local systemd[1]: Starting The Apache HTTP Server... Aug 24 09:20:01 debian11.itzgeek.local systemd[1]: Started The Apache HTTP Server. 

We will now test the Apache webserver to check if it is working as we expect. So, open up a web browser and then go to the following URL.
http://localhost/
OR
http://your-ip-add-ress/
You will get the "Apache2 Debian Default Page". This page confirms that the Apache server is working fine.

Apache HTTP server's default document root is /var/www/html/ where you will place HTML files, and the main configuration file is /etc/apache2/apache2.conf. Additional configuration files are found in the /etc/apache2 directory.

Install MariaDB

MariaDB is the most popular database server, and it is the drop-in replacement of the MySQL server.

Install MariaDB server v10.5 from the Debian base repository.
At the time of writing this article, MariaDB v10.6 is available from the official MariaDB repository. If you want, you can install MariaDB v10.6 on Debian 11ORinstall MySQL 8.0 / 5.7 in place of MariaDB.
sudo apt install -y mariadb-server mariadb-client

Check the status of the MariaDB database service.
sudo systemctl status mariadb

Output:
● mariadb.service - MariaDB 10.5.11 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-08-24 09:31:02 CDT; 2min 42s ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 2951 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Process: 2952 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 2954 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl se> Process: 3015 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 3017 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Main PID: 3001 (mariadbd) Status: "Taking your SQL requests now..." Tasks: 10 (limit: 2321) Memory: 80.5M CPU: 1.027s CGroup: /system.slice/mariadb.service └─3001 /usr/sbin/mariadbd Aug 24 09:31:04 debian11.itzgeek.local /etc/mysql/debian-start[3022]: information_schema Aug 24 09:31:04 debian11.itzgeek.local /etc/mysql/debian-start[3022]: MySQL 

Run the mysql_secure_installation command to improve the security of your MariaDB database installation.

sudo mysql_secure_installation

READ:How to Secure MariaDB installation using mysql_secure_installation

Install PHP

By default Apache server supports the .html files only, not PHP. To have the PHP support, we need to install PHP and the PHP extension package for MariaDB to connect with the database.
Debian 11 comes with PHP v7.4. But, you can install PHP 8.0 on Debian 11 from the SURY repository.
sudo apt install -y php php-mysql libapache2-mod-php

Restart the Apache server after the installation of the PHP packages.
sudo systemctl restart apache2

Test LAMP Stack

To test the LAMP stack, we will place a PHP file on the default document root of the Apache server.
echo "" | sudo tee /var/www/html/info.php

Now, open a web browser and go to the following URL.
http://localhost/info.php
OR
http://your-ip-add-ress/info.php
The page will look like below,

You can scroll further down to see PHP extension details such as MySQL, XML, and PHP variables.

Sumber: disini

Comments

Popular posts from this blog

Cara Disable Antimalware Service Executable di Windows 10

Disadari atau tidak, Windows 10 (dan juga windows-windows lainnya) hadir dengan banyak sekali aplikasi bloatware (aplikasi yang tidak perlu-perlu amat dimiliki oleh end user). Contohnya, adalah aplikasi yang seharusnya sudah tergantikan fungsinya oleh antivirus, seperti Antimalware Service Executable . Aplikasi ini dicurigai membuat Windows 10 mengalami inefisiensi memori/RAM, memakan resource yang tinggi, dengan Load yang tinggi (tanpa limit terkadang). Nah, berikut adalah cara men-disable nya: Tekan tombol Windows + I untuk membuka apliaksi Windows Setting. Pilih icon menu Update and Security Pilih lagi menu disamping kiri Windows Security Pada jendela baru yang muncul, ada pilihan Virus & Threat protection Klik ini Lalu matikan proses Real-time protection tersebut. Dengan Regedit. Buka dialog regedit, Windows + R dan ketik ‘regedit’ Cari Folder regedit ini HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Buat sebuah DWORD baru dengan klik kanan

Setup Debian 11 Official Repository In sources.list (/etc/apt/sources.list)

When you install Debian 11 using a DVD, the OS installer sets the DVD as the source for getting packages for your system if you didn't choose to scan for network mirrors. Due to this reason, the system would ask you to insert a DVD if the disc is not present in the DVD drive when you try to install any software.  Also, the packages on DVD may not be the latest release.  So, we need to get the packages from the Internet. Media change: please insert the disc labeled 'Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04' in the drive '/media/cdrom/' and press [Enter] The /etc/apt/sources.list file with DVD as a source would look something like below. # deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main deb http://security.debian.org/debian-security bullseye-security

Cara Berlangganan ke Akun OnlyFans

Ada dua jenis akun di OnlyFans: akun pengguna dan akun pembuat konten. Jika Anda berlangganan akun OnlyFans, maka Anda adalah pengguna. Sementara beberapa akun pembuat OnlyFans tidak mengenakan biaya untuk melihat konten mereka, yang lain dapat mengenakan biaya bulanan $50. Dalam artikel ini, kami akan menunjukkan cara berlangganan akun OnlyFans di berbagai perangkat. Kami juga akan membahas proses berlangganan akun OnlyFans tanpa kartu kredit atau debit. Cara Berlangganan Akun OnlyFans Tanpa Menggunakan Kartu Kredit Pribadi Anda Sebagai salah satu platform paling populer di industri hiburan dewasa, OnlyFans memiliki 130 juta pelanggan dan 2 juta kreator. Meskipun ada sedikit kontroversi seputar aplikasi ini, ada akun pengguna baru yang dibuat setiap hari. Jika Anda ingin membuat akun pengguna, Anda harus melakukannya di situs OnlyFans. Ingatlah bahwa Anda harus berusia minimal 18 tahun untuk membuat akun OnlyFans.