Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

walkblank/TodoList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

待办事项应用WSGI部署指南

环境要求

  • Ubuntu 20.04+/CentOS 7+
  • Python 3.8+
  • SQLite3
  • Nginx
  • Supervisor/Gunicorn

快速部署

1. 安装依赖

sudo apt update
sudo apt install python3-pip python3-venv nginx

2. 克隆仓库

git clone https://your-repository-url.git
cd TodoList

3. 创建虚拟环境

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

4. 配置应用

export FLASK_APP=app.py
export FLASK_ENV=production
export SECRET_KEY=your-secret-key

Gunicorn配置

1. 安装Gunicorn

pip install gunicorn

2. 创建WSGI入口文件(wsgi.py)

from app import app
if __name__ == "__main__":
 app.run()

3. 启动服务

gunicorn --bind 0.0.0.0:5000 wsgi:app --workers 4

Nginx配置

1. 创建配置文件(/etc/nginx/sites-available/todolist)

server {
 listen 80;
 server_name your-domain.com;
 location / {
 proxy_pass http://127.0.0.1:5000;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 }
 location /static {
 alias /path/to/TodoList/static;
 }
}

2. 启用配置

sudo ln -s /etc/nginx/sites-available/todolist /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

系统服务配置(Systemd)

1. 创建服务文件(/etc/systemd/system/todolist.service)

[Unit]
Description=TodoList WSGI Service
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/path/to/TodoList
Environment="PATH=/path/to/TodoList/venv/bin"
ExecStart=/path/to/TodoList/venv/bin/gunicorn --workers 3 --bind unix:todolist.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target

2. 启动服务

sudo systemctl start todolist
sudo systemctl enable todolist

生产环境注意事项

  1. 配置防火墙:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
  1. 启用HTTPS(使用Certbot):
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx
  1. 定期备份数据库:
cp tasks.db tasks-$(date +%Y%m%d).db
  1. 监控日志:
journalctl -u todolist.service -f

开发模式运行

export FLASK_ENV=development
flask run --host=0.0.0.0 --port=5000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /