一、安装nginx(如果服务器上已经有nginx了,则无需重复安装)

sudo apt-get install nginx

二、nginx配置,例如:/etc/nginx/conf.d/digger.conf

server{
listen 9000;
server_name 127.0.0.1;
root /data/webroot/python/digger; location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
}
}

注:端口随意,不冲突就好;server_name 可以为域名或ip;

三、安装 uwsgi

pip install uwsgi

四、编写入口py文件,保存为 web.py文件(其他文件名也随意)

import os
from bottle import Bottle, request mybottle = Bottle() @mybottle.route('/')
def index():
return 'Hello World!' @mybottle.route('/<spider>/run')
def runSpider(spider):
url = request.query.url
if url is None:
return 'params error'
cwd = os.getcwd().replace('\\', '/')
return os.system('python3 {cwd}/run.py {spider} {url}'.format(cwd=cwd, spider=spider, url=url)) application = mybottle

五、启动 uwsgi(端口要和上面nginx配置的一致)

uwsgi --socket 127.0.0.1:9090 --wsgi-file web.py --master --processes 4 --threads 2 --daemonize /var/log/uwsgi/app/web.log

默认情况下,修改web.py不会立即生效,需要重启uwsgi;如果调试阶段想自动重载,可以增加 --py-autoreload 1 参数

uwsgi --socket 127.0.0.1:9090 --wsgi-file web.py --master --processes 4 --threads 2 --py-autoreload 1 --daemonize /var/log/uwsgi/app/web.log

PS:使用 -- daemonize 参数时为后台守护进程运行,不使用时为当前会话窗口运行

其他配置及参数看这里 ->https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html

六、重启 nginx

nginx -s reload

七、访问 http://127.0.0.1:9000 看看效果

八、使用 supervisor 来管理 uwsgi 进程,请看下文:

《使用 supervisor 来管理 python 进程(以uwsgi为例)》


完。

nginx+uwsgi+bottle python服务器部署的更多相关文章

  1. Flask+Nginx+uWSGI在Ubuntu服务器上的配置

    Flask+Nginx+uWSGI在Ubuntu服务器上的配置 Step1 安装系统环境 Ubuntu服务器选择是阿里云的ECS服务,ECS提供单独的内存\CPU\带宽\存储规格可以选择,并且提供合适 ...

  2. nginx+uwsgi+django+virtualenv+supervisor部署web服务器

    wsgi 全称web server gateway interface,wsgi不是服务器,也不是python模块,只是一种协议,描述web server如何和web application通信的规则 ...

  3. django 本地项目部署uwsgi 以及云服务器部署 uwsgi+Nginx+Docker+MySQL主从

    一 .django 本地项目部署uwsgi 1 本地部署项目 uwsgi安装测试 通过uwsgi 进行简单部署 安装uwsgi命令:pip install uwsgi -i http://pypi.d ...

  4. Nginx+uWSGI+Django+Python+ MySQL 搭建可靠的Python Web服务器

    一.安装所需工具 yum -y install gcc gcc-c++ rpm-build mysql* libtool-ltdl* libtool automake autoconf libtool ...

  5. Nginx+uWSGI+bottle 在Linux上部署

    在/data/lujianxing/bottle 文件夹中创建三个文件: bottle.py bottle的源文件 a.py from bottle import Bottle, run mybott ...

  6. Nginx+uWSGI+Django+Python在Linux上的部署

    搞了一整天,终于以发现自己访问网络的端口是错误的结束了. 首先要安装Nginx,uWSGI,Django,Python,这些都可以再网上查到. 安装好后可以用 whereis 命令查看是否安装好了各种 ...

  7. 基于centos7+nginx+uwsgi+python3+django2.0部署Django项目

    0.序言 本文讲解如何基于centos7+nginx+uwsgi+python3+django2.0把windows上的本地项目部署到云服务器上. 本文服务器上的django项目和虚拟环境的路径将建立 ...

  8. nginx+uwsgi+flask+supervisor 项目部署

    环境 - Linux: Ubuntu 16.04 - uWSGI 2.0.18 - Flask 1.0.2 - supervisor 3.2.0 - nginx/1.8.1 首先区分几个概念 WSGI ...

  9. [技术博客]ubuntu+nginx+uwsgi+Django+https的部署

    ubuntu+nginx+uwsgi+Django+https部署文档 配置机器介绍 操作系统:Ubuntu 18.04.2 LTS 64位 python版本:Python 3.6.7 Django版 ...

随机推荐

  1. 点击 显示红色 小案例 vue

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  2. MySQL之创建用户和授权

    一 权限管理 我们知道我们的最高权限管理者是root用户,它拥有着最高的权限操作.包括select.update.delete.update.grant等操作.那么一般情况在公司之后DBA工程师会创建 ...

  3. Python3的内置函数介绍

    Python3的官网链接:https://docs.python.org/3/library/functions.html?highlight=built#ascii 内置函数介绍 abs 绝对值函数 ...

  4. 第十六章:网络IPC 套接字

    一.IP地址和端口 套接字接口可以用于计算机间通信.目前计算机间使用套接字通讯需要保证处于同一网段. 为了查看是否处于同一网段,我们可以使用IP地址判断. IP地址是计算机在网络中的唯一标识.IP地址 ...

  5. MySQL explain功能展示的各种信息的解释

    1.id: MySQL Query Optimizer 选定的执行计划中查询的序列号. 2.select_type: 所使用的查询类型,主要有以下这几种查询类型.  DEPENDENT SUBQUER ...

  6. LeetCode 1047. Remove All Adjacent Duplicates In String

    1047. Remove All Adjacent Duplicates In String(删除字符串中的所有相邻重复项) 链接:https://leetcode-cn.com/problems/r ...

  7. ASP.NET MVC或者.net Core mvc 页面使用富文本控件的 保存问题

    https://blog.csdn.net/leftfist/article/details/69629394 目前在做的项目存在XSS安全漏洞! 原因是有一些页面使用了富文本编辑框,为了使得其内容可 ...

  8. gitea configure

    gitea configure app.ini APP_NAME = Gitea: Git with a cup of tea RUN_USER = LSGX RUN_MODE = prod [oau ...

  9. tf 2.0

    tf.function和Autograph使用指南-Part 1 "Keras之父发声:TF 2.0 + Keras 深度学习必知的12件事" Effective TensorFl ...

  10. Node中的net模块提供的前端通信

    Node中的net模块提供的前端通信 客户端 业务: 客户端现在要在终端输入内容,然后回车发送内容给服务器 解决: Node中提供了一个叫做 readline 的 模块用于读取命令行内容 [ 单行读取 ...