Contents
FastAPI is one of the most used Python frameworks for building APIs today, especially for AI apps that call language models and return JSON. It’s built on ASGI and usually served by Uvicorn. On hosting that runs Phusion Passenger, the app goes through a small adapter that turns it into a WSGI app. That covers most REST APIs, with clear limits explained below.
What FastAPI needs in production
- A current Python: recent FastAPI and Pydantic 2 releases run on Python 3.9 and newer; 3.12 is the best choice.
- An application server: Uvicorn or another ASGI server, or an adapter to WSGI when the available server is WSGI.
- A virtual environment: with
fastapi,pydanticand your project’s packages. - A database: SQLAlchemy or SQLModel with MySQL/MariaDB, or SQLite for a small API.
- Environment variables: for model API keys and database credentials.
- HTTPS and CORS: if the front end lives on another domain, configure
CORSMiddlewarewith only the domains you allow.
How FastAPI runs on ArabyHost
Passenger runs Python apps through passenger_wsgi.py and expects a WSGI object named application there. So the FastAPI app is wrapped with a2wsgi, a library that converts an ASGI app to WSGI:
source ~/virtualenv/api/3.12/bin/activate && cd ~/api
pip install fastapi a2wsgi
# passenger_wsgi.py
import os, sys
sys.path.insert(0, os.path.dirname(__file__))
from a2wsgi import ASGIMiddleware
from main import app
application = ASGIMiddleware(app)
Deployment in short:
- In cPanel, open Setup Python App, create an app with Python 3.12 and give it a subdomain such as
api.example.com. - Deploy the code from GitHub with Git Version Control, as a ZIP, or from Claude or Cursor through Araby MCP.
- Install the packages over SSH and write
passenger_wsgi.pyas above. - Add environment variables, such as your model’s API key, on the app page, then click Restart.
- Open
https://api.example.com/docsand try the endpoints.
The full walkthrough, with common errors and fixes, is in the FastAPI deployment guide.
What works directly and what needs another approach
| Case | Through the adapter on Passenger |
|---|---|
| JSON REST routes, Pydantic validation | Works |
async def endpoints calling external services with httpx |
Works |
/docs and /redoc |
Work |
| OAuth2 and JWT authentication | Works |
| WebSockets | Don’t work |
| Streaming responses (SSE, StreamingResponse) | May be buffered and arrive at once; test before relying on it |
BackgroundTasks for long jobs |
Ties up the process longer; a background worker is better |
lifespan startup events |
Test them after deploying, or move critical setup to module level |
Long jobs and model calls
If a request waits a long time on a language model or processes a big file, don’t hold the connection open. Store the job in the database, return its ID to the client right away, and let a background worker run it. A cron job keeps that worker alive and restarts it if it stops; the client then polls for the result with the job ID.
Which plan fits FastAPI?
FastAPI needs an AI/Developer plan, the only plans with Python apps and SSH; shared, WordPress and WooCommerce plans run PHP only. AI plans also include Node.js 20 and 24 if your front end is built with React or Next.js, and Claude Code and Codex run on them over SSH. Size the plan by concurrent requests and memory use, since large libraries need more memory; the differences are on the pricing page.
Limits to know up front
- No public ASGI server: you can’t open a port for Uvicorn that visitors reach; requests go through Passenger.
- No WebSockets from Python: an app built around WebSockets or continuous streaming needs a server with wider access.
- No GPU, no Docker, no root: call models through an API rather than running them locally, and install packages in the virtual environment.
- Per-account resources: memory, CPU and process count depend on the plan.
If these limits block your project, read shared hosting vs VPS. ArabyHost doesn’t offer a VPS yet; it’s planned.
On ArabyHost
For a REST API, or the backend of an AI app that calls models through an API, choose an AI/Developer plan, create the app in Setup Python App with the adapter, and deploy from GitHub. You get free SSL issued automatically, the LiteSpeed web server, daily backups and CageFS isolation for your account. If the app stops, the Araby AI assistant reads the error log and explains why, and support is available in Arabic.
FAQ
Can FastAPI run on cPanel hosting?
Yes, if the plan supports Python apps. Wrap the app in an ASGI-to-WSGI adapter such as a2wsgi and Passenger runs it like any other Python app. On ArabyHost that means the AI/Developer plans.
Does the /docs page work after deployment?
Yes. Swagger UI and ReDoc are ordinary HTTP requests. If you deploy under a sub-path instead of its own domain you may need to set root_path, so a subdomain like api.example.com is simpler.
Can I run Uvicorn instead of the adapter?
You can't open a public port for visitors, so Uvicorn can't serve the site's traffic directly. Requests go through Passenger and the adapter; work that isn't tied to a request runs in a background worker kept alive by cron.