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