How to Deploy a Python App in cPanel

How to Deploy a Python App in ChromeLabs cPanel

You can deploy a Python app (Flask, Django, FastAPI) in cPanel using Setup Python App. Follow these steps:


1️⃣ Check if Your Hosting Supports Python

  • Log in to cPanel.
  • Look for "Setup Python App" (inside the Software section).
    • ✅ If available, continue.
    • ❌ If missing, contact your hosting provider (some shared hosting plans don’t support Python).

2️⃣ Create a Python App in cPanel

  1. Go toSetup Python App in cPanel.
  2. Click "Create Application".
  3. Select Python Version (Choose 3.x, like Python 3.8 or 3.9).
  4. Choose an Application Root Folder (e.g., public_html/myapp).
  5. Set the Application URL (e.g., https://yourdomain.com/myapp).
  6. Click "Create" – This sets up a virtual environment for your app.

3️⃣ Upload Your Python App

  • Use File Manager or FTP to upload your Python files inside the Application Root Folder (public_html/myapp).
  • If using Flask, upload:
    • app.py (your main Python file)
    • requirements.txt (list of dependencies)
    • passenger_wsgi.py (needed for deployment)

4️⃣ Install Dependencies

  • In Setup Python App, click "Enter Virtual Environment" (SSH command line opens).
  • Run:
    bash
    pip install -r requirements.txt
    (Installs required Python libraries like Flask, Django, etc.)

5️⃣ Configure Passenger WSGI for Deployment

  • Inside your app folder (public_html/myapp), create a file:
    ???? passenger_wsgi.py
    python
    from app import app as application # Flask Example
    (For Django, import application from wsgi.py instead.)

6️⃣ Restart the Python App


✅ Example: Deploy a Flask App in cPanel

  1. Create app.py in public_html/myapp:

    python
    from flask import Flask app = Flask(__name__) @app.route('/') def home(): return "Hello, Python App is Live on cPanel!" if __name__ == "__main__": app.run()
  2. Create requirements.txt (in the same folder):

    nginx
    flask
  3. Create passenger_wsgi.py:

    python
    from app import app as application
  4. Restart the app in cPanel → Done! ????


⚠️ Common Issues & Fixes

???? 500 Internal Server Error?
✔️ Check passenger_wsgi.py and restart the app.

???? ModuleNotFoundError?
✔️ Run pip install -r requirements.txt inside the virtual environment.

???? Not loading at the domain?
✔️ Make sure the Application URL is correctly set in cPanel.

  • 0 Users Found This Useful
Was this answer helpful?