Giter VIP home page Giter VIP logo

xiaoblog's Introduction

效果

后台

首页

文章页

install in linux

  • flask+gunicorn+nginx install ** install nginx

第一步:下载nginx安装源 rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 第二步:安装nginx yum install nginx 第三步:修改配置文件 配置文件集中在: config: /etc/nginx/nginx.conf 安装目录 config: /etc/sysconfig/nginx pidfile: /var/run/nginx.pid 日志文件在var/log/nginx 默认的配置在 /ect/nginx/conf.d/default.conf 你可以在default里修改,也可以直接在ngnix.conf 里添加配置 第四步:启动服务,关闭

启动命令 service nginx start / systemctl start nginx

停止命令 service nginx stop / systemctl start nginx

重启命令 service nginx restart /systemctl restart nginx

** install gunicorn 第一步:安装:

pip install gunicorn==19.7.1

第二步:配置启动

gunicorn [options] module_name:variable_name

启动类为:

#esayblog.py
from flask import Flask
app = Flask(__name__)

if __name__ == '__main__':
   app.wsgi_app = ProxyFix(app.wsgi_app)
   app.run()

则命令为: gunicorn -w 3 esayblog:app -b 0.0.0.0:8080

-w :线程数 -b: 指定ip和端口 在linux,外网可访问必须配 0.0.0.0:port

** 配置nginx的代理服务: 直接在default.conf 里修改了

server {
     listen 80;
     server_name _; # 外部地址

     location / {
             proxy_pass http://127.0.0.1:8000;
             proxy_redirect     off;
             proxy_set_header   Host                 $http_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;
     }

** 测试访问

http://ip:8000/index.html http://ip.8080/index.html 比较一下 请求的消息头信息有什么区别

重启 gunicorn 1,pstree -ap|grep gunicorn

2,kill -HUP 30080

mysql docker 启动 docker run --name mysql1 -p 3310:3306 -e MYSQL_ROOT_PASSWORD=ouyangBNM -v /opt/mysql/data:/var/lib/mysql -v /opt/mysql/conf:/etc/mysql/conf.d -d mysql

xiaoblog's People

Contributors

minsons2 avatar minsons 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.