Coder Social home page Coder Social logo

burnell-web's Introduction

burnell-web

burnell-web www.burnelltek.com 是一个个人博客网站系统,后端使用Python编写

License

MIT

开发环境

Python3.5.2
Python依赖库:

  1. aiohttp,异步web框架库
  2. jinja2, 前端模板引擎库
  3. aiomysql,mysql异步驱动库
  4. piplow,图片库用于生成验证码

项目结构

conf 配置文件目录
www web目录, 存放.py文件

static 存放静态文件
templates 存放模板文件

部署示例(阿里云ECS Ubuntu14.04)

  1. 安装SSH服务
    sudo apt-get install openssh-server

  2. 安装Python3.5
    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    sudo apt-get install python3.5
    如果无法识别add-apt-repository命令, 则需要进行如下操作:
    sudo apt-get install python-software-properties
    sudo apt-get install software-properties-common

  3. 取消原本的 Python 3.4 ,并将 Python3 链接到最新的 3.5 上:
    sudo mv /usr/bin/python3 /usr/bin/python3-old
    sudo ln -s /usr/bin/python3.5 /usr/bin/python3

  4. 安装Python3包管理工具: python3-pip
    sudo apt-get install python3-pip

  5. 安装需要的Python库
    sudo pip3 install jinja2 aiomysql aiohttp
    如果没有切换Python3链接的动作, 则pip3会把Python库安装在Python3.4上
    安装pillow:
    sudo apt-get install python3.5-dev
    sudo apt-get install libjpeg8-dev zlib1g-dev libfreetype6-dev
    sudo pip3 install pillow

  6. 切换回来链接文件:
    sudo rm /usr/bin/python3
    sudo mv /usr/bin/python3-old /usr/bin/python3

  7. 安装MySQL数据库服务
    sudo apt-get install mysql-server

  8. 安装 Nginx:高性能Web服务器+负责反向代理:
    sudo apt-get install nginx

  9. 安装 Supervisor:监控服务进程的工具
    sudo apt-get install supervisor
    启动 Supervisor: sudo supervisord

  10. 设置MySql可以远程链接
    vim /etc/MySQL/my.cnf找到bind-address = 127.0.0.1
    注释掉这行,如:#bind-address = 127.0.0.1
    重启 MySQL:sudo /etc/init.d/mysql restart
    root登录mysql: mysql -u root -p
    授权远程链接: grant all privileges on . to root@"%" identified by "password" with grant option;
    刷新权限信息: flush privileges;

  11. 设置MySQL支持Emoji表情存储
    找到/etc/mysql路径下的my.cnf文件,添加如下配置:
    [client]
    default-character-set=utf8mb4
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
    init_connect=’SET NAMES utf8mb4'
    [mysql]
    default-character-set=utf8mb4


root登录mysql: mysql -u root -p
已经使用uft8创建的database可以做如下的字符集修改:
ALTER DATABASE 数据库名 CHARACTER SET = utf8mb4 COLLATE = utf8mb4\_unicode\_ci;
已经使用uft8创建的table可以做如下的字符集修改:
ALTER TABLE 表名 CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4\_unicode\_ci;
已经使用utf8创建的字段可以做如下的字符集修改:
ALTER TABLE 表名 CHANGE 字段名 字段名 该字段原来的数据类型 CHARACTER SET utf8mb4 COLLATE utf8mb4\_unicode\_ci;
重启 MySQL:sudo /etc/init.d/mysql restart
  1. 配置Supervisor
    编写一个Supervisor的配置文件burnellweb.conf,存放到/etc/supervisor/conf.d/目录下
    然后重启Supervisor后,就可以随时启动和停止Supervisor管理的服务了
    重启:sudo supervisorctl reload
    启动我们的服务:sudo supervisorctl start burnellweb
    查看状态:sudo supervisorctl status

    [program:burnellweb]
    command     = python3.5 /srv/burnell_web/www/app.py
    directory   = /srv/burnell_web/www
    user        = www-data
    startsecs   = 3
    redirect_stderr         = true
    stdout_logfile_maxbytes = 50MB
    stdout_logfile_backups  = 10
    stdout_logfile          = /srv/burnell_web/log/app.log
    
  2. 配置Nginx
    Supervisor只负责运行app.py,我们还需要配置Nginx,把配置文件burnellweb放到/etc/nginx/sites-available/目录下
    让Nginx重新加载配置文件:sudo /etc/init.d/nginx reload

    server {
        listen      80;
        root       /srv/burnell_web/www;
        access_log /srv/burnell_web/log/access_log;
        error_log  /srv/burnell_web/log/error_log;
        # server_name burnelltek.com;
        client_max_body_size 1m;
        gzip            on;
        gzip_min_length 1024;
        gzip_buffers    4 8k;
        gzip_types      text/css application/x-javascript application/json;
        sendfile on;
        location /favicon.ico {
            root /srv/burnell_web/www/static/img;
        }
        location ~ ^\/static\/.*$ {
            root /srv/burnell_web/www;
        }
        location / {
            proxy_pass       http://127.0.0.1:9000;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    

Release Note:

2017/02/13 V1.1.3 Release

  1. 增加微博登录功能
  2. UI适配移动端
  3. 将首页的作者信息替换为热门博客
  4. 解决不能退出登陆的BUG
  5. 支持emoji表情的输入和显示
  6. 所有博客标题设置为可以换行显示
  7. 使用MathJax支持显示数学公式
  8. 热门博客列表序号从0开始
  9. 增加微博关注功能
  10. 增加微博分享功能
  11. 主页改版,增加微博展示
  12. 博客增加版权信息
  13. 上传图片,取消图片原始名称
  14. 配置档中增加配置域名信息
  15. 微博登陆后获取微博用户的高清头像,替换原来的50*50头像
  16. 管理用户界面显示用户头像(代替Email)
  17. 配置档增加网站名称、ICP备案号、微博APP_KEY和微博UID的配置项

2016/12/01 V1.1.2 Release

  1. 增加博客分类
  2. 增加作者简介
  3. 重新设计首页
  4. 增加热门博客信息
  5. 增加备案信息
  6. 完成博客分页

2016/11/27 V1.1.1 Release

  1. 限制每10秒只能发送一条评论
  2. 注册账号页面需要输入验证码

burnell-web's People

Contributors

burnellliu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.