Proses deployment aplikasi web menggunakan Apache: Difference between revisions
From OnnoCenterWiki
Jump to navigationJump to search
Created page with "Berikut adalah **modul lengkap** untuk bagian **"Proses Deployment Aplikasi Web menggunakan Apache"**, sebagai bagian dari kuliah **Pengenalan Deployment Aplikasi Web** untuk..." |
No edit summary |
||
| Line 1: | Line 1: | ||
==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 | |||
sudo | |||
> Akses `http://localhost` atau IP server di browser → harus muncul "Apache2 Ubuntu Default Page" | |||
` | |||
http:// | |||
` | |||
==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:''' | |||
<pre> | |||
< | <?php | ||
< | echo "Halo dunia dari Apache!"; | ||
?> | |||
</pre> | |||
</ | |||
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== | |||
* [Apache2 Ubuntu Docs](https://ubuntu.com/server/docs/web-servers-apache) | |||
* [DigitalOcean – Apache Virtual Hosts](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu) | |||
* [Let's Encrypt Certbot](https://certbot.eff.org/instructions) | |||
==Pranala Menarik== | |||
* [[Web Programming]] | |||
Latest revision as of 04:46, 8 April 2025
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
- [Apache2 Ubuntu Docs](https://ubuntu.com/server/docs/web-servers-apache)
- [DigitalOcean – Apache Virtual Hosts](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu)
- [Let's Encrypt Certbot](https://certbot.eff.org/instructions)