If you're hosting your application with Prabhu Host, deploying a FastAPI app on cPanel is entirely possible even though FastAPI uses ASGI (unlike Flask or Django which use WSGI). You can run FastAPI using Uvicorn, a high performance ASGI server.
Follow this step-by-step guide to set up your FastAPI project properly:
Step 1: Create a Python Application in cPanel
-
Log in to your Prabhu Host cPanel.
-
Navigate to "Setup Python App" under the Software section.
-
Click Create Application and configure the following:
-
Python Version: Choose Python 3.8 or later.
-
Application Root: e.g.,
/home/username/myfastapi -
Application URL: Select a subdomain or folder where it will run.
-
Application Entry Point: cPanel will auto-generate
passenger_wsgi.py(you will customize this later).
-
-
Click Create to generate the environment.
Step 2: Install FastAPI and Uvicorn
Once the app is created, install the required packages within the virtual environment: