Pustaka Taratsa

Baca teks (EPUB): Proses deployment aplikasi web menggunakan Apache

1 bagian

Teks ini diambil langsung dari berkas EPUB; tata letak dan gambar tidak disertakan. Untuk tampilan lengkap, silakan merujuk pada dokumen asli.

Daftar isi
  1. Proses deployment aplikasi web menggunakan Apache
  2. Tujuan Pembelajaran:
  3. Persiapan Awal
  4. 1. Instalasi Apache Web Server
  5. 2. Instalasi Pendukung (untuk PHP Project)
  6. 3. Struktur Direktori Web
  7. 4. Deploy Aplikasi Web Sederhana
  8. 5. Konfigurasi Virtual Host (Multiple Projects)
  9. 6. Set Hak Akses Folder
  10. 7. Tambahan: HTTPS dengan Let's Encrypt
  11. Praktik Mahasiswa
  12. Referensi
  13. Pranala Menarik

Proses deployment aplikasi web menggunakan Apache

Sumber: https://onnocenter.or.id/wiki/index.php/Proses_deployment_aplikasi_web_menggunakan_Apache

Tujuan Pembelajaran:

Setelah mempelajari modul ini, mahasiswa mampu:

  • Menginstal dan mengonfigurasi Apache Web Server
  • Meletakkan dan menjalankan aplikasi web di server
  • Mengatur virtual host dan domain lokal
  • Mengamankan aplikasi dengan hak akses file yang tepat

Persiapan Awal

Sistem:

  • Ubuntu Server/Desktop 24.04
  • Akses sudo
  • Aplikasi web berbasis PHP/HTML/CSS/JS

1. Instalasi Apache Web Server

Langkah:

sudo apt update
sudo apt install apache2 -y

Cek Status:

sudo systemctl status apache2

> Akses `http://localhost` atau IP server di browser → harus muncul "Apache2 Ubuntu Default Page"

2. Instalasi Pendukung (untuk PHP Project)

sudo apt install php libapache2-mod-php php-mysql -y

Cek Versi PHP:

php -v

3. Struktur Direktori Web

Lokasi default:

`/var/www/html/`

Ganti isi default:

sudo rm /var/www/html/index.html
sudo nano /var/www/html/index.php

Isi contoh:

 <?php
 echo "Halo dunia dari Apache!";
 ?>

Akses di browser: `http://localhost`

4. Deploy Aplikasi Web Sederhana

Misal folder aplikasi bernama `projectku`, letakkan di `/var/www/`

sudo cp -r ~/projectku /var/www/projectku

5. Konfigurasi Virtual Host (Multiple Projects)

Buat File Config Baru:

sudo nano /etc/apache2/sites-available/projectku.conf

Isi contoh:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/projectku
    ServerName projectku.local

    <Directory /var/www/projectku>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/projectku_error.log
    CustomLog ${APACHE_LOG_DIR}/projectku_access.log combined
</VirtualHost> 

Aktifkan Virtual Host:

sudo a2ensite projectku.conf
sudo systemctl reload apache2

(Opsional) Tambah ke `/etc/hosts` untuk domain lokal:

sudo nano /etc/hosts

Tambahkan:

127.0.0.1    projectku.local

> Sekarang akses `http://projectku.local` di browser

6. Set Hak Akses Folder

sudo chown -R www-data:www-data /var/www/projectku
sudo chmod -R 755 /var/www/projectku

7. Tambahan: HTTPS dengan Let's Encrypt

Jika menggunakan domain publik:

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d namadomainkamu.com

Praktik Mahasiswa

Tugas Praktik

  • Install Apache di Ubuntu lokal atau server
  • Deploy proyek web pribadi (HTML/PHP)
  • Konfigurasi virtual host dengan domain lokal (`.local`)
  • Berikan screenshot hasil deploy + isi file konfigurasi

Laporan

  • Penjelasan tahapan deploy
  • Struktur file proyek
  • Kode virtual host (`.conf`)
  • Link GitHub (jika proyek open-source)

Referensi

Pranala Menarik