How To Setup a Django Application on cPanel

To set up a Django application on cPanel, you can follow these general steps:

  1. Log in to your cPanel account and navigate to the "Software" section. Click on "Setup Python App"

  2. Create a new Python application by selecting the appropriate version of Python and specifying the root directory for your application.

  3. Connect to your server via SSH using a terminal application such as PuTTY or Terminal (if you're on a Mac).

  4. Generate a new SSH key pair by running the following command in your terminal: ssh-keygen -t rsa

  5. Follow the prompts to save your public and private key files.

  6. Copy your public key by running the following command: cat ~/.ssh/id_rsa.pub

  7. Add the copied public key to your GitHub account by navigating to the "SSH and GPG keys" section of your GitHub settings and clicking "New SSH Key."

  8. In the "Key" field, paste the copied public key and give it a title to identify it (e.g., "cPanel server key").

  9. Clone your Django application from your private GitHub repository to your cPanel account by running the following command in your terminal: git clone git@github.com:username/repo.git /path/to/application.

  10. Install your application dependencies by running pip install -r /path/to/application/requirements.txt.

  11. Configure your Django application's settings, including database settings and secret key, in the settings.py file.

  12. Set up your application's static and media files by running python manage.py collectstatic and python manage.py compress respectively.

  13. Start your application by running python manage.py runserver


TAGS

django cpanel