Thought for 1s## aaPanel এ Django + Gunicorn + Nginx – সম্পূর্ণ প্রসেস (Scratch থেকে)
Step 1: aaPanel এ Python Manager Install
- aaPanel Dashboard → App Store
- Python Project Manager search করে Install করুন
- Install হলে Python Project Manager → Version Management → Python 3.10 বা 3.12 Install করুন
Step 2: Website তৈরি করুন
- aaPanel → Website → Add Site
- Domain:
screen.ibitltd.com - PHP Version: Pure Static select করুন
- Submit করুন
Step 3: SSH দিয়ে Server এ যান এবং Project Setup করুন
# Website folder এ যান
cd /www/wwwroot/screen.ibitltd.com
# Git clone করুন (যদি না করে থাকেন)
git clone https://github.com/your_repo.git .
# Virtual environment তৈরি করুন
python3 -m venv venv
# Activate করুন
source venv/bin/activate
# Dependencies install করুন
pip install --upgrade pip
pip install django gunicorn
# যদি requirements.txt থাকে
pip install -r requirements.txt
# Database migrate করুন
python manage.py migrate
# Static files collect করুন
python manage.py collectstatic --noinput
# Superuser তৈরি করুন (optional)
python manage.py createsuperuserStep 4: Django Settings Update করুন
config/settings.py (অথবা যেখানে settings.py আছে) file এ:
# ALLOWED_HOSTS এ domain যোগ করুন
ALLOWED_HOSTS = ['screen.ibitltd.com', 'www.screen.ibitltd.com', '127.0.0.1', 'localhost']
# Static files
STATIC_URL = '/static/'
STATIC_ROOT = '/www/wwwroot/screen.ibitltd.com/staticfiles/'
# Media files
MEDIA_URL = '/media/'
MEDIA_ROOT = '/www/wwwroot/screen.ibitltd.com/media/'
# Production এ DEBUG বন্ধ করুন
DEBUG = FalseStep 5: Gunicorn Test করুন
# venv activate আছে কিনা নিশ্চিত করুন
source /www/wwwroot/screen.ibitltd.com/venv/bin/activate
# Test run করুন
gunicorn config.wsgi:application --bind 127.0.0.1:8000
# কাজ করলে Ctrl+C দিয়ে বন্ধ করুনStep 6: Systemd Service তৈরি করুন (Auto Start এর জন্য)
# Service file তৈরি করুন
sudo nano /etc/systemd/system/screen.serviceএই content paste করুন:
[Unit]
Description=Screen Django Gunicorn
After=network.target
[Service]
User=www
Group=www
WorkingDirectory=/www/wwwroot/screen.ibitltd.com
Environment="PATH=/www/wwwroot/screen.ibitltd.com/venv/bin"
ExecStart=/www/wwwroot/screen.ibitltd.com/venv/bin/gunicorn config.wsgi:application --bind 127.0.0.1:8000 --workers 3
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.targetSave: Ctrl + O → Enter → Ctrl + X
# Daemon reload
sudo systemctl daemon-reload
# Service চালু করুন
sudo systemctl start screen
# Auto start enable করুন
sudo systemctl enable screen
# Status check করুন
sudo systemctl status screenStep 7: Nginx Reverse Proxy Setup (aaPanel থেকে)
- aaPanel → Website → screen.ibitltd.com click করুন
- Reverse Proxy tab এ যান
- Add Reverse Proxy click করুন
- এই values দিন:
| Field | Value |
|---|---|
| Proxy name | django |
| Proxy dir | / |
| Target URL | http://127.0.0.1:8000 |
| Sent Domain | $host |
- Confirm click করুন
Step 8: Static Files এর জন্য Nginx Config (Optional)
aaPanel → Website → screen.ibitltd.com → Config
location / { এর আগে এটা যোগ করুন:
location /static/ {
alias /www/wwwroot/screen.ibitltd.com/staticfiles/;
}
location /media/ {
alias /www/wwwroot/screen.ibitltd.com/media/;
}Save করুন।
Step 9: SSL Certificate (HTTPS)
- aaPanel → Website → screen.ibitltd.com → SSL
- Let’s Encrypt select করুন
- Domain tick করুন
- Apply click করুন
- Force HTTPS enable করুন
কাজের Commands (মনে রাখুন)
# Service চালু
sudo systemctl start screen
# Service বন্ধ
sudo systemctl stop screen
# Service restart
sudo systemctl restart screen
# Status দেখা
sudo systemctl status screen
# Live logs দেখা
sudo journalctl -u screen -f
# Gunicorn process দেখা
ps aux | grep gunicornTroubleshooting
# Permission error হলে
sudo chown -R www:www /www/wwwroot/screen.ibitltd.com
# Gunicorn manually test
cd /www/wwwroot/screen.ibitltd.com
source venv/bin/activate
gunicorn config.wsgi:application --bind 127.0.0.1:8000
# Nginx test ও restart
sudo nginx -t
sudo systemctl restart nginxএই সম্পূর্ণ process follow করলে https://screen.ibitltd.com এ আপনার Django site চলবে এবং server restart হলেও automatically চালু থাকবে।