0% found this document useful (0 votes)
27 views2 pages

Cpanel Deployement

This document provides a step-by-step guide for deploying a Django application using cPanel. It covers creating a Python app, installing dependencies, configuring the project, setting up a virtual environment, collecting static files, configuring a web server, setting up a database, migrating the database, and testing the deployment. Additional notes address common issues related to database configuration and necessary code updates for MySQL connectivity.

Uploaded by

shindepankaj562
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Cpanel Deployement

This document provides a step-by-step guide for deploying a Django application using cPanel. It covers creating a Python app, installing dependencies, configuring the project, setting up a virtual environment, collecting static files, configuring a web server, setting up a database, migrating the database, and testing the deployment. Additional notes address common issues related to database configuration and necessary code updates for MySQL connectivity.

Uploaded by

shindepankaj562
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1.

Create a Python app: In cPanel, locate the "Software" section and find the
"Python" or "Python Selector" option. Create a new Python application and select
the desired Python version.

2.Install project dependencies: Using cPanel's terminal or SSH access, navigate to


the root directory of your Django project. Install the project's dependencies by
running pip install -r requirements.txt. Make sure you have a requirements.txt file
listing all the dependencies.

3.Configure the Django project: Modify the project's settings to work with the
production environment. Ensure that the database connection settings, static files
configuration, and other relevant settings are properly configured.

4.Set up a virtual environment: Create a virtual environment for your Django


project. In cPanel's terminal or SSH, navigate to the project directory and run
python -m venv myenv to create the virtual environment.

4.Activate the virtual environment: Activate the virtual environment by running


source myenv/bin/activate.

5.Collect static files: Run python manage.py collectstatic to gather all the static
files from your Django project into a single directory.

6.Set up a web server: In cPanel, locate the "Software" section and find the "Setup
Python App" or similar option. Set up the Python application to specify the
project's root directory, application startup file (e.g., wsgi.py), and the URL
path.

6.Set up a database: In cPanel, create a new MySQL or PostgreSQL database and user.
Update the Django project's settings to use the database credentials provided by
cPanel.

7.Migrate the database: Run python manage.py migrate in cPanel's terminal or SSH to
apply any pending database migrations.

8.Test the deployment: Access your Django project through the provided URL or your
domain name to verify that it's working correctly in the production environment.

note---
1. Check whether you have created a database and configured the same database in
your settings if you are experiencing any database-related issues."py file"
2. To connect to a MySQL database if you are experiencing installation issues with
the mysql-client, use py-mysql.
update below code in __init__ files

init.py
import pymysql
pymysql.install_as_MySQLdb()
3.update passenger.py file with follwing code
from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', '(YOUR PROJECT APP


NAME).settings')

application = get_wsgi_application()
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'banner_apis.settings')

application = get_wsgi_application()

app = application

You might also like