Advertisement

Setup VPS Hostinger, Install Nginx, MariaDB, PHP (LEMP stack), dan Menghubungkan Domain

 


✅ 1. LOGIN KE VPS

Gunakan SSH dari terminal / PowerShell:

ssh root@IP_VPS

Jika pertama kali login, Hostinger akan meminta Anda membuat password baru.


✅ 2. UPDATE SERVER

Selalu update sebelum install apa pun:

apt update && apt upgrade -y

✅ 3. INSTALL NGINX

apt install nginx -y systemctl enable nginx systemctl start nginx

Cek apakah jalan:

systemctl status nginx

Akses server di browser:

http://IP_VPS

✅ 4. INSTALL MARIADB (Database Server)

apt install mariadb-server -y systemctl enable mariadb systemctl start mariadb

Amankan MariaDB:

mysql_secure_installation

Rekomendasi jawaban:

  • Enter current password: ENTER

  • Switch to unix_socket: Y

  • Remove anonymous: Y

  • Disallow root remote login: Y

  • Remove test DB: Y

  • Reload privilege tables: Y


✅ 5. INSTALL PHP + EXTENSIONS

Instal versi terbaru di Ubuntu (misal PHP 8.2):

apt install php-fpm php-mysql php-cli php-curl php-gd php-zip php-mbstring php-xml php-bcmath -y

Cek versi:

php -v

✅ 6. KONFIGURASI NGINX UNTUK PHP

Buat file server block:

nano /etc/nginx/sites-available/domainkamu.com

Isi dengan konfigurasi berikut:

server { listen 80; server_name domainkamu.com www.domainkamu.com; root /var/www/domainkamu.com; index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; } location ~ /\.ht { deny all; } }

Aktifkan site:

ln -s /etc/nginx/sites-available/domainkamu.com /etc/nginx/sites-enabled/ nginx -t systemctl restart nginx

✅ 7. BUAT FOLDER WEB

mkdir -p /var/www/domainkamu.com chown -R www-data:www-data /var/www/domainkamu.com

Buat file test:

echo "<?php phpinfo(); ?>" > /var/www/domainkamu.com/index.php

✅ 8. HUBUNGKAN DOMAIN (DNS HOSTINGER)

Masuk ke Hostinger → DNS Zone domain Anda.

Tambahkan:

A Record

NameTypeValue (IP VPS)TTL
@AIP VPSAuto
wwwAIP VPSAuto

Tunggu propagasi 5–30 menit.


✅ 9. PASANG SSL GRATIS (Let’s Encrypt)

Install Certbot:

apt install certbot python3-certbot-nginx -y

Dapatkan SSL:

certbot --nginx -d domainkamu.com -d www.domainkamu.com

Auto-renew cek:

systemctl status certbot.timer

🎉 VPS ANDA SUDAH SIAP LEMP + DOMAIN TERHUBUNG

Post a Comment

0 Comments