Advertisement

Setup VPS Hostinger Install Apache, MariaDB, PHP Konek Domain

 Berikut panduan lengkap, step-by-step, untuk membuat website di VPS Hostinger (Ubuntu 24) menggunakan Apache + MariaDB + PHP, menghubungkan domain, dan membuatnya bisa diakses publik.


✅ 1. Update Server

Login ke VPS via SSH (dari terminal atau PuTTY):

sudo apt update && sudo apt upgrade -y

✅ 2. Install Apache Web Server

sudo apt install apache2 -y

Cek status:

sudo systemctl status apache2

Jika berjalan, akses IP VPS Anda di browser:

http://IP-VPS-ANDA

Harus muncul halaman default Apache.


✅ 3. Install MariaDB (atau MySQL)

sudo apt install mariadb-server mariadb-client -y

Amankan instalasi:

sudo mysql_secure_installation

Jawaban rekomendasi:

  • Enter current password ⇒ tekan Enter

  • Set root password ⇒ Y

  • Remove anonymous users ⇒ Y

  • Disallow root login remotely ⇒ Y

  • Remove test database ⇒ Y

  • Reload privilege tables ⇒ Y


✅ 4. Install PHP + Module penting

sudo apt install php php-fpm php-mysql php-curl php-zip php-xml php-gd php-intl php-mbstring php-soap php-xmlrpc php-bcmath php-readline php-cli graphviz aspell ghostscript unzip git -y

Cek versi PHP:

php -v

✅ 5. Konfigurasi Virtual Host untuk domain

Misal domain: contohku.com

5.1 Buat folder website

sudo mkdir -p /var/www/contohku.com

5.2 Beri permission

sudo chown -R $USER:$USER /var/www/contohku.com

5.3 Buat file virtual host

sudo nano /etc/apache2/sites-available/contohku.com.conf

Isi dengan:

<VirtualHost *:80> ServerName contohku.com ServerAlias www.contohku.com DocumentRoot /var/www/contohku.com <Directory /var/www/contohku.com> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/contohku_error.log CustomLog ${APACHE_LOG_DIR}/contohku_access.log combined </VirtualHost>

Simpan: CTRL+X → Y → Enter

5.4 Enable site + rewrite module

sudo a2ensite contohku.com.conf sudo a2enmod rewrite sudo systemctl reload apache2

✅ 6. Point Domain ke VPS (DNS Setting)

Masuk ke panel domain (Hostinger / Cloudflare / dll)

Tambahkan record:

A Record

TypeNameValue
A@IP VPS
AwwwIP VPS

Tunggu 1–10 menit (kadang 24 jam untuk propagasi).

Cek:

ping contohku.com

Jika sudah mengarah ke IP VPS, berarti DNS OK.


✅ 7. Tes Website

Buat file:

nano /var/www/contohku.com/index.php

Isi:

<?php phpinfo();

Akses:

http://contohku.com

Jika muncul halaman PHP info → sukses.


✅ 8. (Opsional tapi penting) Install SSL HTTPS Let’s Encrypt

Install certbot:

sudo apt install certbot python3-certbot-apache -y

Dapatkan SSL:

sudo certbot --apache -d contohku.com -d www.contohku.com

Pilih redirect to HTTPS.


✅ 9. Buat Database untuk Website

Masuk ke MariaDB:

sudo mysql -u root -p

Buat database dan user:

CREATE DATABASE webku; CREATE USER 'userweb'@'localhost' IDENTIFIED BY 'passwordku123'; GRANT ALL PRIVILEGES ON webku.* TO 'userweb'@'localhost'; FLUSH PRIVILEGES; EXIT;

🎉 Website Anda siap dipasang!

Sekarang tinggal upload file website ke folder:

/var/www/contohku.com

Misalnya melalui:
✔ SFTP
✔ Git
✔ File manager Hostinger (jika ada)

Sekarang website bisa diakses publik.

Post a Comment

0 Comments