sudo apt update
sudo apt install python3-pip python3-dev nginx
gunicorn --bind 0.0.0.0:5000 wsgi:app
Example of a Gunicorn systemd service file (/etc/systemd/system/myproject.service
):
```
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
Environment="PATH=/home/sammy/myproject/myprojectenv/bin"
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
```
This file starts Gunicorn and directs it to serve your Flask application.
Example of an Nginx server block (/etc/nginx/sites-available/myproject
):
```
server {
listen 80;
server_name your_domain www.your_domain;
location / {
include proxy_params;
proxy_pass http://unix:/home/sammy/myproject/myproject.sock;
}
}
```
This file tells Nginx to listen on port 80 and to proxy requests to the Gunicorn server.