- Install supervisor and other dependencies
sudo apt install python3-venv supervisor nginx - setup virtual env
sudo python3 -m venv env - Fastapi and Uvicorn
sudo pip3 install -r requirements.txt
-
change ownership of the files to www-data
sudo chown www-data:www-data -R /var/www -
test the start script by executing
./var/www/fastapi/start.sh -
setup supervisor to do the process management by copying etc/supervisor/conf.d/fastapi-demo.conf into location
-
setup nginx by copying
/etc/nginx/sites-available/fastapi.confinto location also dont forget to link to/etc/nginx/sites-enabled byln -s -
update and restart supervisor (try commands below)
sudo supervisorctl rereadsudo supervisorctl updatesudo supervisorctl restart allsudo supervisorctl status(to see status of uvicorn supervisor processes)
-
If error check the error logs from the file specified in
etc/supervisor/conf.d/fastapi-demo.conf -
Then restart nginx
sudo service nginx restart
https://www.youtube.com/watch?v=E5IhKYT7ecU&
Please post your comments, subcribe and follow me on twitter @ppshobi