1. SSH to Your Server
ssh root@<server-ip>
2. Find Login Credentials
- Default user:
django - Password stored in:
/root/.cloudzy-creds
(Optional) Change the default password: passwd django
3. Switch to the App User
su - django
4. PostgreSQL (Optional)
If PostgreSQL was installed, set up DB and user (example):
sudo -u postgres psql
CREATE DATABASE <db>;
CREATE USER <user> WITH PASSWORD '<password>';
GRANT ALL PRIVILEGES ON DATABASE <db> TO <user>;
q
Then update settings.py DATABASES with host localhost, database name, user, and password. Run python manage.py migrate.
5. Deploy Your App
A sample Flask app is already running and accessible at: http://<server-ip
To deploy your own app:
- Navigate to your application directory (or clone a new project):
cd~/django_app - (Optional) Replace default app:
gitclone<your_repo_url> . - Activate the virtual environment:
sourcevenv/bin/activate - Install required packages:
pip install -r requirements.txt - Adjust
settings.py: setALLOWED_HOSTSto your domain/IP and ensureSTATIC_ROOTexists. - Migrate database:
python manage.py migrate - Collect static into
STATIC_ROOT:python manage.py collectstatic --noinput - Restart Gunicorn to apply changes:
sudo systemctl restart gunicorn - Restart Nginx:
sudo systemctl restart nginx
6. Access Your App
Your Django app is available at: http://<server-ip
Nginx is reverse-proxying requests to Gunicorn via Unix socket.
7. Change Port or Domain?
To adjust domain, port, or add SSL:
- Edit Nginx site config:
sudo nano /etc/nginx/sites-available/gunicorn_django - Test configuration:
sudo nginx -t - Reload Nginx:
sudo systemctl restart nginx
8. Enable HTTPS (Optional)
Use Certbot to enable HTTPS.
Install certbot:
sudo apt install certbot python3-certbot-nginx -y
Get certificates & update Nginx automatically:
sudo certbot --nginx -d example.com
Test:
nginx -t && sudo systemctl reload nginx