Django

A Python web framework that encourages rapid development and clean, pragmatic design.

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:

  1. Navigate to your application directory (or clone a new project): cd ~/django_app
  2. (Optional) Replace default app: git clone <your_repo_url> .
  3. Activate the virtual environment: source venv/bin/activate
  4. Install required packages: pip install -r requirements.txt
  5. Adjust settings.py: set ALLOWED_HOSTS to your domain/IP and ensure STATIC_ROOT exists.
  6. Migrate database: python manage.py migrate
  7. Collect static into STATIC_ROOT: python manage.py collectstatic --noinput
  8. Restart Gunicorn to apply changes: sudo systemctl restart gunicorn
  9. 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:

  1. Edit Nginx site config: sudo nano /etc/nginx/sites-available/gunicorn_django
  2. Test configuration: sudo nginx -t
  3. 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
Currently unavailable.

Application Details