Created
February 8, 2026 05:26
-
-
Save abdullahainun/091fe35294a43f6d484288ac3ac05ca9 to your computer and use it in GitHub Desktop.
setup server tkj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # --- PRE-SETUP --- | |
| echo "Membersihkan konfigurasi lama..." | |
| docker-compose down 2>/dev/null | |
| # Menghapus database lama agar fresh install | |
| sudo rm -rf ./zabbix/db_data | |
| # 1. Buat struktur folder yang dibutuhkan | |
| echo "Membuat folder project..." | |
| mkdir -p apache/htdocs apache/conf/extra zabbix/db_data technitium/config | |
| sudo chown -R $USER:$USER ./apache ./zabbix ./technitium | |
| # 2. Buat file index.html percobaan | |
| echo "<h1>Selamat Datang di WWW.TKJ.LOCAL</h1>" > apache/htdocs/index.html | |
| # 3. Ambil konfigurasi default Apache | |
| echo "Mengambil konfigurasi default Apache..." | |
| docker run --rm httpd:latest cat /usr/local/apache2/conf/httpd.conf > ./apache/conf/httpd.conf | |
| # 4. Aktifkan modul Proxy dan Vhosts | |
| echo "Mengonfigurasi modul Apache..." | |
| sed -i 's/#LoadModule proxy_module/LoadModule proxy_module/' ./apache/conf/httpd.conf | |
| sed -i 's/#LoadModule proxy_http_module/LoadModule proxy_http_module/' ./apache/conf/httpd.conf | |
| sed -i 's/#Include conf\/extra\/httpd-vhosts.conf/Include conf\/extra\/httpd-vhosts.conf/' ./apache/conf/httpd.conf | |
| # 5. Buat file Virtual Hosts | |
| echo "Membuat file Virtual Hosts..." | |
| cat <<EOF > ./apache/conf/extra/httpd-vhosts.conf | |
| <VirtualHost *:80> | |
| ServerName www.tkj.local | |
| DocumentRoot "/usr/local/apache2/htdocs" | |
| </VirtualHost> | |
| <VirtualHost *:80> | |
| ServerName tn.tkj.local | |
| ProxyPreserveHost On | |
| ProxyPass / http://technitium-dns:5380/ | |
| ProxyPassReverse / http://technitium-dns:5380/ | |
| </VirtualHost> | |
| <VirtualHost *:80> | |
| ServerName mon.tkj.local | |
| ProxyPreserveHost On | |
| ProxyPass / http://zabbix-web:8080/ | |
| ProxyPassReverse / http://zabbix-web:8080/ | |
| </VirtualHost> | |
| EOF | |
| # 6. Buat file docker-compose.yml (Zabbix menggunakan varian -mysql) | |
| echo "Membuat file docker-compose.yml..." | |
| cat <<EOF > docker-compose.yml | |
| version: '3.3' | |
| services: | |
| technitium: | |
| image: technitium/dns-server:latest | |
| container_name: technitium-dns | |
| hostname: technitium-dns | |
| ports: | |
| - "53:53/udp" | |
| - "53:53/tcp" | |
| - "5380:5380/tcp" | |
| environment: | |
| - DNS_SERVER_DOMAIN=dns-server | |
| volumes: | |
| - ./technitium/config:/etc/dns/config | |
| restart: always | |
| networks: | |
| - monitoring_net | |
| apache2: | |
| image: httpd:latest | |
| container_name: apache-server | |
| ports: | |
| - "80:80" | |
| volumes: | |
| - ./apache/htdocs:/usr/local/apache2/htdocs | |
| - ./apache/conf/extra/httpd-vhosts.conf:/usr/local/apache2/conf/extra/httpd-vhosts.conf | |
| - ./apache/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf | |
| restart: always | |
| networks: | |
| - monitoring_net | |
| zabbix-db: | |
| image: mariadb:10.6 | |
| container_name: zabbix-db | |
| command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_bin", "--log_bin_trust_function_creators=1"] | |
| environment: | |
| - MARIADB_DATABASE=zabbix | |
| - MARIADB_USER=zabbix | |
| - MARIADB_PASSWORD=zabbix_pwd | |
| - MARIADB_ROOT_PASSWORD=root_pwd | |
| volumes: | |
| - ./zabbix/db_data:/var/lib/mysql | |
| restart: always | |
| networks: | |
| - monitoring_net | |
| zabbix-server: | |
| image: zabbix/zabbix-server-mysql:latest | |
| container_name: zabbix-server | |
| ports: | |
| - "10051:10051" | |
| environment: | |
| - DB_SERVER_HOST=zabbix-db | |
| - MYSQL_DATABASE=zabbix | |
| - MYSQL_USER=zabbix | |
| - MYSQL_PASSWORD=zabbix_pwd | |
| depends_on: | |
| - zabbix-db | |
| restart: always | |
| networks: | |
| - monitoring_net | |
| zabbix-web: | |
| image: zabbix/zabbix-web-apache-mysql:latest | |
| container_name: zabbix-web | |
| ports: | |
| - "8081:8080" | |
| environment: | |
| - ZBX_SERVER_HOST=zabbix-server | |
| - DB_SERVER_HOST=zabbix-db | |
| - MYSQL_DATABASE=zabbix | |
| - MYSQL_USER=zabbix | |
| - MYSQL_PASSWORD=zabbix_pwd | |
| depends_on: | |
| - zabbix-server | |
| restart: always | |
| networks: | |
| - monitoring_net | |
| networks: | |
| monitoring_net: | |
| driver: bridge | |
| EOF | |
| # 7. Jalankan Docker | |
| echo "Menjalankan container..." | |
| docker-compose up -d | |
| echo "------------------------------------------------" | |
| echo "SETUP SELESAI DENGAN VARIAN MYSQL!" | |
| echo "------------------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment