To set up a Django application on cPanel, you can follow these general steps:
-
Log in to your cPanel account and navigate to the "Software" section. Click on "Setup Python App"
-
Create a new Python application by selecting the appropriate version of Python and specifying the root directory for your application.
-
Connect to your server via SSH using a terminal application such as PuTTY or Terminal (if you're on a Mac).
-
Generate a new SSH key pair by running the following command in your terminal:
ssh-keygen -t rsa
-
Follow the prompts to save your public and private key files.
-
Copy your public key by running the following command:
cat ~/.ssh/id_rsa.pub
-
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."
-
In the "Key" field, paste the copied public key and give it a title to identify it (e.g., "cPanel server key").
-
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
. -
Install your application dependencies by running
pip install -r /path/to/application/requirements.txt
. -
Configure your Django application's settings, including database settings and secret key, in the
settings.py
file. -
Set up your application's static and media files by running
python manage.py collectstatic
andpython manage.py compress
respectively. -
Start your application by running
python manage.py runserver
TAGS