{"id":31130274,"url":"https://github.com/rijumia/deploy_django_application_on_shared_hosting_using_cpanel","last_synced_at":"2026-05-11T07:04:19.034Z","repository":{"id":314276272,"uuid":"1054319875","full_name":"rijumia/Deploy_Django_Application_On_Shared_Hosting_Using_Cpanel","owner":"rijumia","description":"Step-by-step guide to deploying Django applications on shared hosting with cPanel. Covers project preparation, Python app setup, database configuration, file uploads, and static/media handling with WhiteNoise. Includes instructions for both terminal and non-terminal access.","archived":false,"fork":false,"pushed_at":"2025-09-11T12:49:31.000Z","size":195,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-11T15:48:55.111Z","etag":null,"topics":["cpanel","deployment","django","django-deployment","django-web-application-host","djangoweb","gunicorn","mysql","passenger","python","rijumia","shared-hosting","staticfiles","vps-server","vps-setup","web-hosting","whitenoise","wsgi"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rijumia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-10T17:08:42.000Z","updated_at":"2025-09-11T12:49:35.000Z","dependencies_parsed_at":"2025-09-11T15:48:56.453Z","dependency_job_id":"0ebea47c-fca9-4ba2-9b91-1398e18b6b28","html_url":"https://github.com/rijumia/Deploy_Django_Application_On_Shared_Hosting_Using_Cpanel","commit_stats":null,"previous_names":["rijumia/deploy_django_application_on_shared_hosting_using_cpanel"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/rijumia/Deploy_Django_Application_On_Shared_Hosting_Using_Cpanel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rijumia%2FDeploy_Django_Application_On_Shared_Hosting_Using_Cpanel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rijumia%2FDeploy_Django_Application_On_Shared_Hosting_Using_Cpanel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rijumia%2FDeploy_Django_Application_On_Shared_Hosting_Using_Cpanel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rijumia%2FDeploy_Django_Application_On_Shared_Hosting_Using_Cpanel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rijumia","download_url":"https://codeload.github.com/rijumia/Deploy_Django_Application_On_Shared_Hosting_Using_Cpanel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rijumia%2FDeploy_Django_Application_On_Shared_Hosting_Using_Cpanel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275696239,"owners_count":25511354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpanel","deployment","django","django-deployment","django-web-application-host","djangoweb","gunicorn","mysql","passenger","python","rijumia","shared-hosting","staticfiles","vps-server","vps-setup","web-hosting","whitenoise","wsgi"],"created_at":"2025-09-18T02:17:58.291Z","updated_at":"2025-09-18T02:18:00.495Z","avatar_url":"https://github.com/rijumia.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀Deploy-Django-Application-on-Shared-Hosting-using-Cpanel\n\n## 📌Context\n- [Step-01: Prepare Django Project](#step-01-prepare-django-project)\n- [Step-02: Logging Into the Cpanel](#-step-02-logged-in-into-the-cpanel-dashboard)\n- [Step-03: Create Subdomain](#-step-03--create-sub-domain-if-needed)\n- [Step-04: Setup Application](#-step-04--setup-application)\n- [Step-05: Setup MySQL Database](#-step-05--setup-mysql-database-if-you-want)\n- [Step-06: Upload Project Files](#-step-06--upload-project-files)\n- [Step-07: Final Setup](#-step-07--final-setup)\n    - [If You Have Terminal Access](#if-you-have-terminal)\n    - [If You Don't Have Terminal Access](#if-you-dont-have-terminal-access)\n\n## ✅1️⃣ Step-01: Prepare Django Project\n\n### 🔹Modify `settings.py`\n\n- Make sure `DEBUG = False` in `settings.py`\n- Set `APPOWED_HOSTS` to your domain or used `*` to accept any domain\n    \n    ```python\n    ALLOWED_HOSTS = [\"yourdomain.com\"] # you can used multiple domain or subdomain\n    \n    # or\n    ALLOWED_HOSTS = [\"*\"]\n    ```\n    \n- Integrate`whitenoise`  inside the `INSTALLED_APPS and MIDDLEWARE` in `settings.py`:\n    \n    ```python\n    INSTALLED_APPS = [\n        'django.contrib.admin',\n        'django.contrib.auth',\n        'django.contrib.contenttypes',\n        'django.contrib.sessions',\n        'django.contrib.messages',\n        'whitenoise.runserver_nostatic', # This must be added before 'django.contrib.staticfiles'\n        'django.contrib.staticfiles',\n        'portfolioapp',\n    ]\n    ```\n    \n    ```python\n    MIDDLEWARE = [\n        'django.middleware.security.SecurityMiddleware',\n        'django.contrib.sessions.middleware.SessionMiddleware',\n        'whitenoise.middleware.WhiteNoiseMiddleware', # This must be added here after SecurityMiddleware \u0026 SessionMiddleware\n        'django.middleware.common.CommonMiddleware',\n        'django.middleware.csrf.CsrfViewMiddleware',\n        'django.contrib.auth.middleware.AuthenticationMiddleware',\n        'django.contrib.messages.middleware.MessageMiddleware',\n        'django.middleware.clickjacking.XFrameOptionsMiddleware',\n    ]\n    ```\n    \n- Set `Static \u0026 Media Files` root in `settings.py`\n    \n    ```python\n    STATIC_URL = 'static/'\n    MEDIA_URL = '/media/'\n    STATIC_ROOT = BASE_DIR / 'staticfiles/'\n    MEDIA_ROOT = BASE_DIR / 'media/'\n    STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'\n    ```\n    \n- Final Overview of the `settings.py`\n    \n    ```python\n    DEBUG = False\n    ALLOWED_HOSTS = [\"yourdomain.com\"]\n    \n    INSTALLED_APPS = [\n        'django.contrib.admin',\n        'django.contrib.auth',\n        'django.contrib.contenttypes',\n        'django.contrib.sessions',\n        'django.contrib.messages',\n        'whitenoise.runserver_nostatic', # This must be added before 'django.contrib.staticfiles'\n        'django.contrib.staticfiles',\n        'portfolioapp',\n    ]\n    \n    MIDDLEWARE = [\n        'django.middleware.security.SecurityMiddleware',\n        'django.contrib.sessions.middleware.SessionMiddleware',\n        'whitenoise.middleware.WhiteNoiseMiddleware', # This must be added here after SecurityMiddleware \u0026 SessionMiddleware\n        'django.middleware.common.CommonMiddleware',\n        'django.middleware.csrf.CsrfViewMiddleware',\n        'django.contrib.auth.middleware.AuthenticationMiddleware',\n        'django.contrib.messages.middleware.MessageMiddleware',\n        'django.middleware.clickjacking.XFrameOptionsMiddleware',\n    ]\n    \n    STATIC_URL = 'static/'\n    MEDIA_URL = '/media/'\n    STATIC_ROOT = BASE_DIR / 'staticfiles/'\n    MEDIA_ROOT = BASE_DIR / 'media/'\n    STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'\n    ```\n    \n\n### 🔹Modify `urls.py`\n\n- Modify main project directory `urls.py` file.\n    \n    ```python\n    from django.contrib import admin\n    from django.conf import settings\n    from django.conf.urls.static import static\n    from django.views.static import serve\n    from django.urls import path, include, re_path\n    \n    urlpatterns = [\n        path('admin/', admin.site.urls),\n        # Other paths...\n    ]\n    urlpatterns+=re_path(r'^static/(?P\u003cpath\u003e.*)$', serve, {'document_root': settings.STATIC_ROOT}),\n    urlpatterns+=re_path(r'^media/(?P\u003cpath\u003e.*)$', serve, {'document_root': settings.MEDIA_ROOT}),\n    ```\n    \n\n### 🔹Prepare `requirements.txt` file\n\n- Add all required the packages and their version that you used in this project. Also must be add `gunicorn, whitenoise` packages for development. Otherwise some time you fetch lots of issue for static and media file after deployment.:\n    \n    ```python\n    Django==5.2.3\n    gunicorn==23.0.0\n    pillow==10.3.0\n    whitenoise==6.9.0\n    ```\n    For auto create `requirements.txt` used below code:\n   ```python\n    pip freeze \u003e requirements.txt\n   ```\n📒[Go To Context](#context)\n\n## ✅2️⃣ Step-02: Logged-in into the Cpanel Dashboard\n\n## ✅3️⃣ Step-03:  Create Sub-Domain (if needed):\n\n- After login search `Domains`\n![image.png](/docs-img/image-3.png)\n- From the `Domains` Page click to the `Create A New Domain` button.\n- Then create and submit\n\n    ```python\n    #Ex: test.yourmaindomain.com\n    ```\n\n📒[Go To Context](#context)\n## ✅4️⃣ Step-04:  Setup Application:\n\n- Go to `Setup Python App` page\n![image.png](/docs-img/image-4.png)\n- Click `Create Application` button\n- `Python Version:`  Select Python Version\n- `Application root:`  Enter project directory name. Where you upload your project files.\n- `Application URL:` Select the `Domain or Subdomain`\n- Then hit the `Create` button.\n![image.png](/docs-img/image-4.1.png)\n\n📒[Go To Context](#context)\n\n## ✅5️⃣ Step-05:  Setup MySQL Database (If you want)\n\n### 🔹Setup Database on the Cpanel\n\n- Go to `Manage My Databases`\n- On the Create New Database section set the Database name then hit the `Create Database` button\n    \n    ![image.png](/docs-img/image-5.1.png)\n    \n- Then scroll down and find `Add New User` section. Here set the database `username, password`\n    \n    ![image.png](/docs-img/image-5.2.png)\n    \n- Again scroll down and find `Add User To Database` section. Then select `User and Database`\n    \n    ![image.png](/docs-img/image-5.3.png)\n    \n- After Add it redirect to the `Manage User Privileges` from here select `ALL PRIVILEGES` then click `Make Changes` button.\n    \n    ![image.png](/docs-img/image-5.4.png)\n    \n\n`**🚨 Alert:**` Must be copy the Database Name, Username and Password. Because need to configure database on the settings.py\n\n### 🔹Database Configuration\n\n```python\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.mysql',\n        'NAME': 'your_database_name',\n        'USER': 'your_database_username',\n        'PASSWORD': 'database_user_password',\n        'HOST': 'yourhostdomain.com',\n        'PORT': '3306',\n    }\n}\n```\n\n📒[Go To Context](#context)\n\n## ✅6️⃣ Step-06:  Upload Project Files\n\n- Go to `File Manager` page\n- Find the Application root directory.\n- Upload the project file as `zip`\n- Edit the `passenger_wsgi.py` and add below line and save it.\n    \n    ```python\n    from yourProjectname.wsgi import application\n    ```\n    \n    `**🚨 Note:**` Must change the `yourProjectname` based on your project name\n\n📒[Go To Context](#context)\n\n## ✅7️⃣ Step-07:  Final Setup\n\n- Go to `Setup Python App` page\n- Select your app and click Edit Icon\n\n### 🔹If You Have Terminal:\n\n- From the application copy the `virtual environment` command\n- Open the Terminal  and Paste the command\n- Then run the below command:\n- Install requirements file:\n    \n    ```bash\n    pip install -r requirements.txt\n    ```\n    \n- Migration and Migrate the database:\n    \n    ```bash\n    python manage.py makemigrations\n    ```\n    \n    ```bash\n    python manage.py migrate\n    ```\n    \n- Then Apply collect static command to collects all static files from apps and puts them into one central directory for easy serving in production:\n    \n    ```python\n    python manage.py collectstatic\n    ```\n\n📒[Go To Context](#context)\n\n### 🔹If You Don’t Have Terminal Access:\n\n- From the Application Setup Page apply the command manually\n- Write and Add `requirements.txt` into this section and click `Run Pip Install`. Note: Sometimes it send error message first try. If you fetch error then run again.\n\n    ![image.png](/docs-img/image-7.1.png)\n\n- Then into this section run other command and click `Run Script` button without `py or python`:\n\n    ![image.png](/docs-img/image-7.2.png)\n\n    After that click the `RESTART` button. Now you can visit your application.\n\n📒[Go To Context](#context)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frijumia%2Fdeploy_django_application_on_shared_hosting_using_cpanel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frijumia%2Fdeploy_django_application_on_shared_hosting_using_cpanel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frijumia%2Fdeploy_django_application_on_shared_hosting_using_cpanel/lists"}