当前位置:首页 > 编程技术 > 正文

nginx python 如何部署

nginx python 如何部署

在Nginx中部署Python应用,通常有几种方式,以下是一些常见的方法: 1. 使用WSGI服务器(如Gunicorn)步骤:1. 安装Gunicorn: ```ba...

在Nginx中部署Python应用,通常有几种方式,以下是一些常见的方法:

1. 使用WSGI服务器(如Gunicorn)

步骤:

1. 安装Gunicorn:

```bash

pip install gunicorn

```

2. 运行Gunicorn:

```bash

gunicorn your_project:app

```

其中 `your_project` 是你的Python项目名,`app` 是你的应用实例名。

3. 配置Nginx:

在Nginx的配置文件中添加以下内容:

```nginx

server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://127.0.0.1:8000; Gunicorn默认监听8000端口

include proxy_params;

最新文章