# Konfigurasi Apache Virtual Host untuk IKIWAE

## File Konfigurasi

Proyek ini memiliki virtual host untuk:

1. **pos.local** - Backend/Admin Panel (POS System)
2. **api.pos.local** - REST API
3. **adminer.local** - Database Management Tool (Adminer)

## Langkah-langkah Instalasi

### 1. Buat Direktori Log

```bash
mkdir -p /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/logs
```

### 2. Copy File Konfigurasi ke Apache

Untuk macOS dengan Homebrew Apache:

```bash
# Copy semua file konfigurasi
sudo cp /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/*.conf /usr/local/etc/httpd/vhosts/

# Atau jika menggunakan Apache bawaan macOS:
# sudo cp /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/*.conf /etc/apache2/other/
```

### 3. Edit File Hosts

Tambahkan entry berikut ke file `/etc/hosts`:

```bash
sudo nano /etc/hosts
```

Tambahkan baris berikut:

```
127.0.0.1   pos.local
127.0.0.1   api.pos.local
```

### 4. Aktifkan Modul Apache yang Diperlukan

```bash
# Untuk Homebrew Apache
brew services stop httpd

# Edit httpd.conf
nano /usr/local/etc/httpd/httpd.conf
```

Pastikan modul berikut tidak di-comment (hapus # di depannya):

```apache
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
```

Dan pastikan line ini ada:

```apache
# Virtual hosts
Include /usr/local/etc/httpd/vhosts/*.conf
```

### 5. Test Konfigurasi Apache

```bash
# Test konfigurasi
sudo apachectl configtest

# Atau untuk Homebrew:
httpd -t
```

### 6. Restart Apache

```bash
# Homebrew Apache
brew services restart httpd

# Atau Apache bawaan macOS:
# sudo apachectl restart
```

## Akses Aplikasi

Setelah setup selesai, Anda dapat mengakses:

- **Backend/POS**: http://pos.local
- **API**: http://api.pos.local
- **Adminer**: http://adminer.local

### Database Connection (Adminer)

- **System**: MySQL
- **Server**: 127.0.0.1
- **Username**: root
- **Password**: password
- **Database**: goldensense

## Troubleshooting

### Permission Denied

Jika mengalami error "Permission denied", pastikan Apache user memiliki akses ke direktori:

```bash
# Check Apache user
ps aux | grep httpd | grep -v grep

# Berikan permission (sesuaikan dengan user Apache, biasanya _www atau daemon)
sudo chmod -R 755 /Users/grafihouse/Documents/Projects/Www/ikiwae/
```

### 404 Not Found untuk Pretty URLs

Pastikan:
1. Modul `mod_rewrite` sudah aktif
2. `AllowOverride All` sudah diset di konfigurasi
3. File `.htaccess` ada di masing-masing folder web

### Cek Error Log

```bash
tail -f /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/logs/backend-error.log
tail -f /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/logs/frontend-error.log
tail -f /Users/grafihouse/Documents/Projects/Www/ikiwae/apache/logs/api-error.log
```

## Alternative: Konfigurasi Single File

Jika Anda ingin menggunakan single file untuk semua virtual hosts, Anda bisa menggabungkan ketiga konfigurasi menjadi satu file `ikiwae-all.conf`.

## Kebutuhan

- Apache 2.4+
- PHP 7.0+ (atau versi yang digunakan proyek)
- mod_rewrite enabled
- mod_php atau PHP-FPM configured
