Search code examples
linuxapachefastapiuvicorn

Migrating from Apache2 to Uvicorn in RHEL to use FastAPI?


We have a RHEL 7.9 machine that hosts several web tools that we use on our intranet. The web server is Apache2 v2.4.6. This setup has been working well. Our tools are mostly PHP, Perl and Python scripts.

We need to provide some APIs for applications on other hosts. We are considering installing FastAPI.

What I would like to know is...

  • FastAPI uses uvicorn as it's web server. Can uvicorn replace Apache2? Would this migration be difficult?
  • Can FastAPI work with Apache2?
  • How can I ensure that uvicorn will start if the machine is restarted?
  • Am I misunderstanding something basic about how Apache2, Uvicorn and FastAPI work?

(Side note, I am trying to get our Unix support team to upgrade us to RHEL 9)


Solution

    1. It highly depends on what you are trying to achieve. You definetely won't be able to run your PHP web tools on Uvicorn
    2. FastAPI is based on ASGI specification, which is not supported by Apache2. There are also several differences on how fastapi and python itself work as they do not have compilation and deployment at all
    3. systemd, k8s and so on. It's not the problem web server should solve