项目概述
开源项目简介:Serverless Python
项目地址
https://github.com/zappa/Zappa
项目页面预览

关键指标
- Stars:3672
- 主要语言:Python
- License:MIT License
- 最近更新:2026-01-08T05:59:02Z
- 默认分支:master
本站高速下载(国内可用)
点击下载(本站镜像)
– SHA256:d48fbf6da72025a4e6be6df4e1ae887d19de94ce21db0141bc1e7f2074fb8d52
安装部署要点(README 精选)
Installation and Configuration
Before you begin, make sure you are running Python 3.9/3.10/3.11/3.12/3.13/3.14 and you have a valid AWS account and your AWS credentials file is properly installed.
Zappa can easily be installed through pip, like so:
$ pip install zappa
Please note that Zappa must be installed into your project’s virtual environment. The virtual environment name should not be the same as the Zappa project name, as this may cause errors.
(If you use pyenv and love to manage virtualenvs with pyenv-virtualenv, you just have to call pyenv local [your_venv_name] and it’s ready. Conda users should comment here.)
Next, you’ll need to define your local and server-side settings.
Running the Initial Setup / Settings
Zappa can automatically set up your deployment settings for you with the init command:
$ zappa init
This will automatically detect your application type (Flask/Django – Pyramid users see here) and help you define your deployment configuration settings. Once you finish initialization, you’ll have a file named zappa_settings.json in your project directory defining your basic deployment settings. It will probably look something like this for most WSGI apps:
{
// The name of your stage
"dev": {
// The name of your S3 bucket
"s3_bucket": "lambda",
// The modular python path to your WSGI application function.
// In Flask and Bottle, this is your 'app' object.
// Flask (your_module.py):
// app = Flask()
// Bottle (your_module.py):
// app = bottle.default_app()
"app_function": "your_module.app"
}
}
or for Django:
{
"dev": { // The name of your stage
"s3_bucket": "lambda", // The name of your S3 bucket
"django_settings": "your_project.settings" // The python path to your Django settings.
}
}
Psst: If you’re deploying a Django application with Zappa for the first time, you might want to read Edgar Roman’s Django Zappa Guide.
You can define as many stages as your like – we recommend having dev, staging, and production.
Nested JSON Configurations
The settings command supports complex nested JSON structures for advanced configurations like CORS options, VPC settings, and environment variables:
Configure CORS with nested JSON
$ zappa settings --stage production \
--config 'cors_options={"allowedOrigins":["*"],"allowedMethods":["GET","POST","PUT"]}'
Configure VPC settings
$ zappa settings --stage production \
--config 'vpc_config={"SubnetIds":["subnet-123","subnet-456"],"SecurityGroupIds":["sg-789"]}'
Configure environment variables
$ zappa settings --stage production \
--config 'environment_variables={"DATABASE_URL":"postgres://...","API_KEY":"secret"}'
Configure Lambda layers
$ zappa settings --stage production \
--config 'layers=["arn:aws:lambda:us-east-1:123:layer:mylayer:1","arn:aws:lambda:us-east-1:123:layer:another:2"]'
You can mix primitive values with complex nested structures:
$ zappa settings --stage production \
--config project_name=myapp \
--config memory_size=1024 \
--config binary_support=true \
--config 'cors_options={"allowedOrigins":["https://example.com"]}' \
--config 'environment_variables={"DB_HOST":"localhost","DB_PORT":"5432"}'
The same nested JSON syntax works with environment variables:
$ export ZAPPA_CORS_OPTIONS='{"allowedOrigins":["*"],"allowedMethods":["GET","POST"]}'
$ export ZAPPA_VPC_CONFIG='{"SubnetIds":["subnet-1","subnet-2"],"SecurityGroupIds":["sg-1"]}'
$ zappa settings --stage production
Now, you’re ready to deploy!
Basic Usage
常用命令(从 README 提取)
$ pip install zappa
$ zappa init
$ zappa deploy
$ zappa settings --stage production \
--config project_name=myapp \
--config memory_size=1024 \
--config timeout_seconds=60
$ export ZAPPA_PROJECT_NAME=myapp
$ export ZAPPA_MEMORY_SIZE=1024
$ zappa settings --stage production
通用部署说明
- 下载源码并阅读 README
- 安装依赖(pip/npm/yarn 等)
- 配置环境变量(API Key、模型路径、数据库等)
- 启动服务并测试访问
- 上线建议:Nginx 反代 + HTTPS + 进程守护(systemd / pm2)
免责声明与版权说明
本文仅做开源项目整理与教程索引,源码版权归原作者所有,请遵循对应 License 合规使用。







暂无评论内容