Install LEMP Stack (Nginx, MariaDB, PHP) on Debian 12: Perbedaan antara revisi

Dari Catatan Pak Samsul
Loncat ke navigasi Loncat ke pencarian
 
(9 revisi perantara oleh pengguna yang sama tidak ditampilkan)
Baris 1: Baris 1:
=== Tahap 1 : Lakukan update dan upgrade reposetory ===
= Tahap 1 : Lakukan update dan upgrade reposetory =
  sudo apt update && sudo apt upgrade
  sudo apt update && sudo apt upgrade


=== Tahap 2 : Install Nginx Web Server on Debian 12 ===
= Tahap 2 : Install Nginx Web Server on Debian 12 =
  sudo apt install nginx
  sudo apt install nginx
Test Konfigurasi Nginx :  
Test Konfigurasi Nginx :  
  sudo nginx -t
  sudo nginx -t


=== Tahap 3 : Install MariaDB Server on Debian 12 ===
= Tahap 3 : Install MariaDB Server on Debian 12 =
  sudo apt install mariadb-server
  sudo apt install mariadb-server


=== Securing MariaDB Server ===
= Tahap 4 : Securing MariaDB Server =
  sudo mysql_secure_installation
  sudo mysql_secure_installation


=== Testing MariaDB Installation ===
==== Testing MariaDB Installation ====
<code>sudo mysql</code>
sudo mysql


=== Tahap 5: Install PHP on Debian 12 ===
= Tahap 5: Install PHP on Debian 12 =
<code>sudo apt install php-fpm php-mysql php-gd php-cli php-curl php-mbstring php-zip php-opcache php-xml</code>
sudo apt install php-fpm php-mysql php-gd php-cli php-curl php-mbstring php-zip php-opcache php-xml


=== Configure Nginx to Execute PHP Files ===
=== Configure Nginx to Execute PHP Files ===
Menentukan lokasi penyimpanan.
Menentukan lokasi penyimpanan.


<code>location / {# First attempt to serve request as file, then# as directory, then fall back to displaying a 404. try_files $uri $uri/ =404;}</code>
location / {                 # First attempt to serve request as file, then# as directory, then fall back to displaying a 404. try_files $uri $uri/ =404;}<br />


Menjadi :
location / {
    try_files $uri $uri/ /index.php?$args;}


Menjadi :  
Menjadi :  


 
location ~ \.php$ {
<code>location / {    try_files $uri $uri/ /index.php?$args;}</code>
  include snippets/fastcgi-php.conf;
 
   fastcgi_pass unix:/var/run/php/php-fpm.sock;}
 
Menjadi :
 
 
<code>location ~ \.php$ {include snippets/fastcgi-php.conf;    fastcgi_pass unix:/var/run/php/php-fpm.sock;}</code>
 


Terakhir restart Nginx.
Terakhir restart Nginx.
sudo systemctl restart nginx


=== Test Your Debian 12 LEMP Installation ===
=== Test Your Debian 12 LEMP Installation ===
Buat file index.html
Buat file index.html


isi sebagai berikut :  
isi sebagai berikut :  


<code>echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/test.php</code>
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/test.php

Revisi terkini sejak 14 Mei 2024 16.23

Tahap 1 : Lakukan update dan upgrade reposetory

sudo apt update && sudo apt upgrade

Tahap 2 : Install Nginx Web Server on Debian 12

sudo apt install nginx

Test Konfigurasi Nginx :

sudo nginx -t

Tahap 3 : Install MariaDB Server on Debian 12

sudo apt install mariadb-server

Tahap 4 : Securing MariaDB Server

sudo mysql_secure_installation

Testing MariaDB Installation

sudo mysql

Tahap 5: Install PHP on Debian 12

sudo apt install php-fpm php-mysql php-gd php-cli php-curl php-mbstring php-zip php-opcache php-xml

Configure Nginx to Execute PHP Files

Menentukan lokasi penyimpanan.

location / {                 # First attempt to serve request as file, then# as directory, then fall back to displaying a 404. try_files $uri $uri/ =404;}

Menjadi :

location / {
   try_files $uri $uri/ /index.php?$args;}

Menjadi :

location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  fastcgi_pass unix:/var/run/php/php-fpm.sock;}

Terakhir restart Nginx.

sudo systemctl restart nginx

Test Your Debian 12 LEMP Installation

Buat file index.html

isi sebagai berikut :

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/test.php