LEMP adalah sekumpulan perangkat lunak yang dapat digunakan untuk menyajikan halaman web dinamis dan aplikasi web yang ditulis dalam PHP. Istilah ini merupakan akronim yang mendeskripsikan sistem operasi Linux, dengan server web Nginx (diucapkan seperti “Engine-X”). Data backend disimpan dalam database MySQL dan pemrosesan dinamis ditangani oleh PHP.
Panduan ini menunjukkan cara memasang tumpukan LEMP di server Ubuntu. Sistem operasi Ubuntu menangani bagian Linux dari tumpukan tersebut. Kami akan menjelaskan cara menjalankan dan mengoperasikan komponen lainnya.
Install Nginx
Lakukan update repositori terlebih dahulu
sudo apt update
Selanjutnya lakukan proses Install nginx
sudo apt install nginx -y
Lakukan pengecekan apakah nginx sudah berhasil di Install dengan
systemctl status nginx.service
Pastikan service dari nginx sudah Running

Nginx Config
Buat Folder Public_html
sudo mkdir -p /var/www/domain.com/public
sudo chown -R www-data:www-data /var/www/domain.com
Buat File Config
sudo nano /etc/nginx/sites-available/domain.com
Masukkan Config Berikut ini
server {
listen 80;
server_name domain.com www.domain.com;
root /var/www/domain.com/public;
index index.php index.html index.htm;
access_log /var/log/nginx/domain.com.access.log;
error_log /var/log/nginx/domain.com.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock; # PHP 8.3 socket
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Enbale Konfigurasi
sudo ln -s /etc/nginx/sites-available/domain.com /etc/nginx/sites-enabled/
Test Kofigurasi dan Restart Nginx
sudo nginx -t
sudo systemctl reload nginx
Install MySQL
Lakukan Install mysql
sudo apt install mysql-server -y
Konfigurasi MySQL
sudo mysql_secure_installation
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: Y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Skipping password set for root as authentication with auth_socket is used by default.
If you would like to use password authentication instead, this can be done with the "ALTER_USER" command.
See https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management for more information.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success.
Ubah password untuk user root MySQL
sudo mysql
Ubah password sesuai yang diinginkan
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Y0UR$TR0NGP4SSWORD';
FLUSH PRIVILEGES;
EXIT;
Install PHP
Pada kali ini akan melakukan instalasi versi 7.4, 8.1, dan 8.3
Tambahkan PPA (Personal Package Archive) ondrej/php, agar kita bisa mengakses dan menginstal multiple versi PHP seperti PHP 7.4, 8.0, 8.1, 8.2, dll.
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
Install PHP Versi 7.4
sudo apt install php7.4 php7.4-cli php7.4-fpm php7.4-mysql php7.4-xml php7.4-mbstring php7.4-curl php7.4-zip php7.4-gd php7.4-bcmath -y
Install PHP Versi 8.1
sudo apt install php8.1 php8.1-cli php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring php8.1-curl php8.1-zip php8.1-gd php8.1-bcmath -y
Install PHP Versi 8.3
sudo apt install php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip php8.3-gd php8.3-bcmath -y
Konfigurasi update-alternatives untuk PHP CLI agar bisa mengubah versi php yang diingikan
sudo update-alternatives --install /usr/bin/php php /usr/bin/php7.4 74
sudo update-alternatives --install /usr/bin/php php /usr/bin/php8.1 81
sudo update-alternatives --install /usr/bin/php php /usr/bin/php8.3 83
Jika ingin menghubah versi PPH dapat dilakukan dengan cara dan ketik pada nomor php yang akan dipilih
sudo update-alternatives --config php
There are 4 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php.default 100 auto mode
1 /usr/bin/php.default 100 manual mode
* 2 /usr/bin/php7.4 74 manual mode
3 /usr/bin/php8.1 81 manual mode
4 /usr/bin/php8.3 83 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
Cek versi php yang digunakan dengan
php -v
lakukan restart terhadap php FPM
sudo systemctl restart php7.4-fpm
sudo systemctl restart php8.1-fpm
sudo systemctl restart php8.3-fpm
Pastikan PHP FPM berjalan
sudo systemctl status php7.4-fpm
sudo systemctl status php8.1-fpm
sudo systemctl status php8.3-fpm
Install Composer
Install Composer secara global
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
Cek apakah composer sudah terinstall
composer --version
Jika ingin menggunakan composer dengan versi php dapat ubah versi php terlebih dahulu dengan update-alternatives