fix : deploy bug

This commit is contained in:
SatryaIrvannurYudha
2026-06-09 14:35:36 +07:00
parent 865e4bd577
commit 39572b461d
2 changed files with 41 additions and 5 deletions
+16
View File
@@ -0,0 +1,16 @@
FROM php:8.1-apache
# 1. Install ekstensi PHP mysqli yang diperlukan untuk koneksi database
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
# 2. Aktifkan modul rewrite Apache (jika diperlukan untuk routing/htaccess)
RUN a2enmod rewrite
# 3. Salin semua file dari repositori Git ke dalam folder web server Apache
COPY . /var/www/html/
# 4. Atur hak akses folder agar bisa dibaca oleh web server
RUN chown -R www-data:www-data /var/www/html
# 5. Buka port 80 untuk akses web
EXPOSE 80
+25 -5
View File
@@ -1,6 +1,26 @@
<?php
$host = "127.0.0.1";
$user = "root";
$pass = "";
$db = "webgis";
$conn = mysqli_connect($host, $user, $pass, $db);
// Deteksi otomatis lokasi server berjalan
if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1') {
// ----------------------------------------------------
// KONFIGURASI LOCALHOST (Laptop Anda)
// ----------------------------------------------------
$host = "127.0.0.1";
$user = "root";
$pass = "";
$db = "webgis";
} else {
$host = "127.0.0.1";
$user = "root";
$pass = "";
$db = "webgis";
}
// Membuat koneksi database
$conn = mysqli_connect($host, $user, $pass, $db);
// Cek jika koneksi gagal
if (!$conn) {
die("Koneksi database gagal: " . mysqli_connect_error());
}
?>