# Arif Billah Backend — cPanel Deployment Guide

**Yes — Django backend can be hosted on cPanel.**

Domain: `mdarifbillah.com`  
cPanel user: `mdarifbillah`  
Server IP: `104.234.134.136`

> **Security:** Change cPanel and MySQL passwords after deployment. Never commit `.env` to git.

---

## Recommended URLs

| Service | URL |
|---------|-----|
| Portfolio | `https://mdarifbillah.com` |
| **API (Django)** | `https://api.mdarifbillah.com` |
| Admin dashboard | `https://admin.mdarifbillah.com` (optional) |

---

## Step 1 — MySQL database (cPanel)

1. Login: `https://mdarifbillah.com:2083`
2. **MySQL Databases** → Create database `arif_billah` → becomes **`mdarifbillah_arif_billah`**
3. Create user `arifuser` → becomes **`mdarifbillah_arifuser`**
4. Add user to database with **ALL PRIVILEGES**

---

## Step 2 — Import SQL

1. **phpMyAdmin** → select **`mdarifbillah_arif_billah`**
2. **Import** → upload `arif_billah.sql` → **Go**

---

## Step 3 — Upload backend

Upload `backend/` folder (without `venv/`) to:

```
/home/mdarifbillah/backend/
```

---

## Step 4 — Subdomain

**Domains** → Create subdomain **`api`** → `api.mdarifbillah.com`

---

## Step 5 — Setup Python App

**Software** → **Setup Python App** → **Create Application**

| Field | Value |
|-------|-------|
| Python | 3.11+ |
| Application root | `backend` |
| Application URL | `api.mdarifbillah.com` |
| Startup file | `passenger_wsgi.py` |
| Entry point | `application` |

---

## Step 6 — `.env` on server

Create `/home/mdarifbillah/backend/.env` from `.env.production.example`:

```env
DEBUG=False
SECRET_KEY=your-long-random-secret

ALLOWED_HOSTS=mdarifbillah.com,www.mdarifbillah.com,api.mdarifbillah.com,104.234.134.136
CSRF_TRUSTED_ORIGINS=https://mdarifbillah.com,https://www.mdarifbillah.com,https://api.mdarifbillah.com

DB_NAME=mdarifbillah_arif_billah
DB_USER=mdarifbillah_arifuser
DB_PASSWORD=YOUR_MYSQL_PASSWORD
DB_HOST=localhost
DB_USE_PYMYSQL=True

CORS_ALLOWED_ORIGINS=https://mdarifbillah.com,https://www.mdarifbillah.com
```

---

## Step 7 — Install & restart

Terminal or Python App pip install:

```bash
cd ~/backend
source ~/virtualenv/backend/3.11/bin/activate
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py create_admin
```

Restart Python App in cPanel.

---

## Step 8 — Test

```
https://api.mdarifbillah.com/
https://api.mdarifbillah.com/api/contact/
```

---

## Step 9 — Frontend

```env
NEXT_PUBLIC_API_URL=https://api.mdarifbillah.com/api
```

---

## Admin login

`admin@gmail.com` / `12345678` — change on production.
