Skip to main content

How To Install Nginx, MariaDB, PHP (LEMP Stack) on Debian 11

The LEMP stack, which stands for Linux (the operating system), Nginx (the webserver), MariaDB/MySQL (the database), and PHP (the programming language), is the perfect platform to host traffic-intensive dynamic websites and applications.

In this post, we will see how to Install LEMP Stack on Debian 11.


To install the LEMP stack on Debian 11, you need to have sudo privileges on the system.

Install LEMP Stack

Install Linux

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

Proceed to the installation of AMP (Nginx v1.20, PHP-FPM v7.4, MariaDB v10.5) on Debian 11.

Install Nginx

Nginx is a free, open-source webserver that provides HTTP, reverse proxy, caching, and load-balancing functionality. It's a great alternative to Apache, and it's easy to set up.

Install below packages.
sudo apt update sudo apt install -y curl gnupg2 ca-certificates lsb-release

Download the Nginx repository signing key and add it to the system.
wget gpg --no-default-keyring --keyring ./nginx_signing_key_temp.gpg --import ./nginx_signing.key gpg --no-default-keyring --keyring ./nginx_signing_key_temp.gpg --export > ./nginx_signing_key.gpg sudo mv nginx_signing_key.gpg /etc/apt/trusted.gpg.d/

Add Nginx repository to the system.
echo "deb `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list

Install Nginx package using the following command.
sudo apt update sudo apt install -y nginx

Start the Nginx service after the installation.
sudo systemctl start nginx

Open a web browser and visit the below URL.
You will get the welcome page that confirms that Nginx has been successfully installed and is up and running.

Nginx's default document root in Debian 11 is /usr/share/nginx/html/. The configuration files are found under /etc/nginx/ directory.

Install MariaDB

MariaDB is a drop-in replacement for MySQL that supports all standard MySQL features. We will set up MariaDB as part of a LEMP (Linux, Nginx, MariaDB/MySQL, PHP) stack in our installation.

Install the MariaDB server v10.5 from the Debian 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

MariaDB service should be up and running at this moment. First, check the status of the MariaDB service using the below command.
sudo systemctl status mariadb

Next, make the MariaDB server secure by running the mysql_secure_installation command.

Install PHP

The PHP FastCGI Process Manager (FPM) is an alternative PHP FastCGI implementation with additional features useful for bigger and busier sites. It can handle a lot more requests per second than other PHP FastCGI implementations.

Install php-fpm package and PHP MySQL extension.
Debian 11 comes with PHP v7.4. However, you can install PHP 8.0 on Debian 11 from the SURY repository.
sudo apt install -y php-fpm php-mysql php-cli

Edit the configuration file.
sudo nano /etc/php/7.4/fpm/pool.d/www.conf

Change the ownership and group from www-data to nginx for Unix socket.
listen.owner = nginx = nginx

Create Virtual Host

Now, create a virtual host on the Nginx server for the following details to test the LEMP stack.
Server Name: site.itzgeek.localDocument Root : /usr/share/nginx/html/site.itzgeek.local

Create a virtual host configuration file site.itzgeek.local.conf in /etc/nginx/conf.d/ directory.
sudo nano /etc/nginx/conf.d/site.itzgeek.local.conf

Add the following content.
server { server_name site.itzgeek.local; root /usr/share/nginx/html/site.itzgeek.local; location / { index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/site.itzgeek.local$fastcgi_script_name; } }

Create the document root directory for the virtual host.
sudo mkdir /usr/share/nginx/html/site.itzgeek.local

Place a PHP file onto the document root.
echo "" | sudo tee /usr/share/nginx/html/site.itzgeek.local/index.php

Restart the Nginx and PHP-FPM services.
sudo systemctl restart nginx sudo systemctl restart php7.4-fpm 

Test LEMP Stack

First, create a host entry for your domain (site.itzgeek.local) in the /etc/hosts file to test the LEMP stack locally. Then, open up your web browser and type your domain name in the web address.
The page will look like below:

As you can see in the screenshot, the PHP is working through FPM/FastCGI (Server API).

Scroll the page further down to view the PHP support for MySQL, XML, and other extensions.

Sumber: disini


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 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.