Table of Contents
如何安装及使用
安装需要的package
pip install -r requirements.txt
配置config
查看配置详细介绍
注释下面代码
因为如果不注释的话 初始化数据库 会报错
文件位置: maple/topic/forms.py
category = SelectField( _('Category:'), choices=[(b.id, b.board + ' --' + b.parent_board) for b in Board.query.all()], coerce=int)
初始化数据库
python manage.py db init python manage.py db migrate -m "first migrate" python manage.py db upgrade
ok,将第三步中注释的内容恢复
创建管理员账户
python manager.py create_user
本地搭建
登陆并进入后台
python manager.py runserver
Visit http://forums.localhost:5000/admin
服务端搭建
参考 http://flask.pocoo.org/docs/0.11/deploying/
以我的配置为例:
配置nginx
server { listen 80; server_name _; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_pass http://127.0.0.1:8000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
配置supervior
[program:forums] user=www command=/home/www/forums/venv/bin/gunicorn run:app -c /home/www/forums/gunicorn.conf directory=/home/www/forums autostart=true autorestart=true stdout_logfile=/home/www/forums/logs/gunicorn_supervisor.log
配置gunicorn
workers = 2 bind = '127.0.0.1:8000'
启动
确定配置无误后
supervisord -c /etc/supervisord.conf supervisorctl -c /etc/supervisord.conf reload