template deploy lengkap untuk React, PHP, dan Python (Flask) implementasi ontologi

Di bawah ini aku kasih template deploy lengkap untuk React, PHP, dan Python (Flask), baik untuk localhost maupun hosting (shared/VPS). Kamu bisa pilih sesuai teknologi yang kamu pakai:

1. React (Frontend) – Deployment

A. Localhost (Development)

npm install
npm start

B. Production (Hosting via Netlify / Vercel / VPS)

npm run build

Folder build/ akan berisi file HTML/JS statis.

Deploy ke:

  • Netlify:

  • Vercel:

    • npx vercel di root proyek, ikuti instruksinya

    • Nginx (VPS): Tambahkan konfigurasi di /etc/nginx/sites-available/react-app:

      server {
        listen 80;
        server_name yourdomain.com;
        root /var/www/react-app/build;
      
        index index.html index.htm;
        location / {
          try_files $uri /index.html;
        }
      }

      Lalu:

      sudo ln -s /etc/nginx/sites-available/react-app /etc/nginx/sites-enabled/
      sudo systemctl restart nginx

2. PHP (Backend + Frontend)

A. Localhost (XAMPP/Laragon)

  • Tempatkan index.php ke dalam htdocs (XAMPP) atau www (Laragon).

  • Akses di http://localhost/index.php.

B. Hosting (Shared Hosting / cPanel)

  • Upload file .php ke public_html.

  • Pastikan Fuseki dapat diakses dari IP server (pastikan tidak diblok oleh firewall).

  • Jika perlu, Fuseki bisa dijalankan di server yang sama (VPS saja).

3. Python Flask API – Deploy

A. Localhost (Development)

pip install flask requests
python app.py

Akses di: http://localhost:5000/api/books

B. VPS (Ubuntu + Gunicorn + Nginx)

1. Setup Virtualenv dan Install:

sudo apt install python3-pip python3-venv nginx
python3 -m venv venv
source venv/bin/activate
pip install flask gunicorn requests

2. Jalankan Gunicorn:

gunicorn -w 4 -b 127.0.0.1:8000 app:app

3. Nginx Config (/etc/nginx/sites-available/flask-app)

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
sudo ln -s /etc/nginx/sites-available/flask-app /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Struktur Folder Ideal

/project-root
│
├── react-frontend/
│   └── build/               # hasil dari npm run build
│
├── flask-backend/
│   └── app.py               # REST API
│
├── php-version/
│   └── index.php            # SPA PHP
│
└── library.owl              # Ontologi

Selamat hari raya idul fitri

0 Comments