centOS 6.5采用python+nginx+uwsgi实现爬金十财经日历
上一篇中有关于安装nginx、python、uwsgi的过程,这里不再重述。下面是有关在具体布署中的一些过程和问题处理
一、因为用到了bs4(BeautifulSoup)\paste\lxml所以这些先安装,pip安装即可
二、nginx端口更改为了8001,防止与原来已经存在的apache服务器冲突,uwsgi使用了8010的端口。其中在测试的时候发现返回为200 ok,但没有输出内容,后来网上看到要注意python的版本,我用的是python3。
# test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"] # python3
#return ["Hello World"] # python2
三、测试uwsgi的时候用
uwsgi --http :8001 --wsgi-file test.py
但实际使用中要开机启动,所以参考了http://www.cnblogs.com/xiongpq/p/3381069.html,
#! /bin/sh
# chkconfig:
# Description: Startup script for uwsgi webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add uwsgi' ### BEGIN INIT INFO
# Provides: uwsgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop:
# Short-Description: starts the uwsgi web server
# Description: starts uwsgi using start-stop-daemon
### END INIT INFO # Author: licess
# website: http://lnmp.org PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="uwsgi daemon"
NAME=uwsgi8010
DAEMON=/usr/bin/uwsgi //注意你的安装位置
CONFIGFILE=/etc/$NAME.ini
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME set -e
[ -x "$DAEMON" ] || exit do_start() {
$DAEMON $CONFIGFILE || echo -n "uwsgi already running"
} do_stop() {
$DAEMON --stop $PIDFILE || echo -n "uwsgi not running"
rm -f $PIDFILE
echo "$DAEMON STOPED."
} do_reload() {
$DAEMON --reload $PIDFILE || echo -n "uwsgi can't reload"
} do_status() {
ps aux|grep $DAEMON
} case "$1" in
status)
echo -en "Status $NAME: \n"
do_status
;;
start)
echo -en "Starting $NAME: \n"
do_start
;;
stop)
echo -en "Stopping $NAME: \n"
do_stop
;;
reload|graceful)
echo -en "Reloading $NAME: \n"
do_reload
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload}" >&
exit
;;
esac exit uwsgi8010
终端执行
-- 添加服务
chkconfig --add uwsgi9090
-- 设置开机启动
chkconfig uwsgi9090 on
四、本人接口的存放位置放在了/var/www目录下,包括uwsgi8010.ini和日志文件uwsgi8010.log
别外要注意的是
- paste.request.parse_querystring(environ)
- environ返回的是list,里面的参数是tulp,注意读取的方法和顺序
centOS 6.5采用python+nginx+uwsgi实现爬金十财经日历的更多相关文章
- python+Nginx+uWSGI使用说明
安装环境 Remote: CentOS 7.4 x64 (django.example.com) Python: Python3.6.5 Django: Django 2.0.4 nWSGI: uw ...
- python nginx+uwsgi+WSGI 处理请求详解
https://blog.csdn.net/a519640026/article/details/76157976 请求从 Nginx 到 uwsgi 到 django 交互概览 作为python w ...
- centos python nginx uwsgi
先更新系统,并安装编译环境等等. yum update yum install python python-devel libxml2 libxml2-devel python-setuptools ...
- centos 7部署graphite(nginx+uwsgi)
http://www.debugrun.com/a/o5qyP9W.htmlhttp://blog.csdn.net/tsingfu1986/article/details/44239503 http ...
- Centos+nginx+uwsgi+Python多站点环境搭建
前言 新公司的第一个项目,服务器端打算用python作为restful api.所以需要在Centos上搭建nginx+fastcgi+python的开发环境,但后面网上很多言论都说uwsgi比fas ...
- Centos下搭建 nginx+uwsgi+python
python做web应用最麻烦的还是配置服务器了,此话不假,光中间件就有好几种选择,fastcgi.wsgi.uwsgi,难 免让人眼花缭乱. 而听说uwsgi的效率是fastcgi和wsgi的10倍 ...
- CentOS 6.5下安装Python+Django+Nginx+uWSGI
1.安装Python31.1先安装zlib库及其他三方库安装uWSGI时需要使用zlib,否则执行python uwsgiconfig.py --build时会报ImportError,就是因为在安装 ...
- Nginx+uWSGI+Django+Python+ MySQL 搭建可靠的Python Web服务器
一.安装所需工具 yum -y install gcc gcc-c++ rpm-build mysql* libtool-ltdl* libtool automake autoconf libtool ...
- 使用Nginx+Uwsgi部署Python Flask项目
第一次用Flask做Web(也是第一次用Python做Web),在部署的时候遇到了不少问题,现在将过程就下来,供在这方面也有疑惑的人参考.(PS:使用Apache+mod_wsgi部署模式的可以参考另 ...
随机推荐
- Django 中如何让外部访问本地的静态资源
简单使用 在Django中打开一个入口,让别人可以访问media文件 在settings中配置 MEDIA_ROOT=os.path.join(BASE_DIR,'media') 在路由中配置 fro ...
- 如果让我重来,我会选择C和(或者)Python。
如果让我重来,我会选择C和(或者)Python.Python语法和库更丰富,上手更容易,使用更方便.C简单直接,学习成本不高,贴近底层,能帮助了解底层细节.先强调:1. 语言只是工具,假以时日,你都会 ...
- 【示例】Spring Quartz入门
JAVA 针对定时任务,有 Timer,Scheduler, Quartz 等几种实现方式,其中最常用的应该就是 Quartz 了. 一. Quartz的基本概念 在开始之前,我们必须了解以下的几个基 ...
- Matconvnet 的一些记录
Matconvnet 的一些记录 Example code from ADNet: Action-Decision Networks for Visual Tracking with Deep Rei ...
- WebPack填坑笔记
loader使用时不需要用require引入,在使用plugins(插件)才需要使用require引入 压缩js代码会导致热更新失效 所以开发环境先不要进行压缩 给css加前缀的 postcss-lo ...
- 什么情况下用断言?assert
可以再预计正常情况下不会到达的任何位置上放置断言,断言可以用于验证传递给私有方法的参数.不俺的参数过,断言不应该用于验证传递给公有方法的参数,因为不管是否启用了断言,公有方法都必须检查其参数.不过,既 ...
- entity framework浅谈
1. 什么是EF 微软提供的ORM工具. ORM让开发人员节省数据库访问代码的时间. 将更多的时间放在业务逻辑层面上. 开发人员使用linq语言, 对数据库进行操作. 2. EF的使用场景 EF有三种 ...
- Lintcode241-String to Integer - Naive
Given a string, convert it to an integer. You may assume the string is a valid integer number that c ...
- ArrayList.clear、=null、new Arraylist之间的对比区别
参考博文 1.使用ArrayList的对象方法clear() List list = new ArrayList(); List list1 = list; list.add(1); list.add ...
- JqGrid 列时间格式化
{name:'createTime',index:'createTime',label:"创建时间", editable:false,formatter:"date&qu ...