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部署模式的可以参考另 ...
随机推荐
- ODAC(V9.5.15) 学习笔记(四)TMemDataSet (2)
2.索引与过滤 名称 类型 说明 IndexFieldNames string 设置排序字段列表,每个字段之间通过分号分割.每个字段后可以有以下几种排序选项: ASC 升序 DESC ...
- 从0开始安装fedora23的笔记-- 以及使用fedora的常规问题-2
在shell中, 你是可以连续输入多个语句的, 中间用分号; 连接 也可以把这些多个语句放到一个函数中, 函数的话,便于多次引用. 而且 "封装" 为函数后, 可以用set查看到这 ...
- 【第四十章】Spring Boot 自定义拦截器
1.首先编写拦截器代码 package com.sarnath.interceptor; import javax.servlet.http.HttpServletRequest; import ja ...
- AGC006D Median Pyramid Hard
闲扯 今天模拟的题,应该是挺简单的二分和贪心,就是没想出来,我好弱啊 顺便ORZ聚聚BLUESKY007,踩爆我了 思路 今天发现中位数性质如此优秀 二分最后塔顶的数,大于等于它的数变为1,小于它的数 ...
- PTA 7-3 jmu-ds-单链表的基本运算(15 分)
jmu-ds-单链表的基本运算(15 分) 实现单链表的基本运算:初始化.插入.删除.求表的长度.判空.释放.(1)初始化单链表L,输出L->next的值:(2)依次采用尾插法插入元素:输入分两 ...
- AngularJS 笔记1
2017-03-23 本文更新链接: http://www.cnblogs.com/daysme/p/6606805.html 什么是 angularjs 2009年有两个外国人创建,后由谷歌收购并开 ...
- js点击显示隐藏
这个栗子…… 可以不吃,先预设一个变量表示div的状态,例子中0是显示的,一开始是隐藏的.当点击时判断状态是显示0的还是隐藏1的:如果是显示的就把div隐藏,再把变量改变为1.再次点击时把会判断到变量 ...
- Lintcode449-Char to Integer-Naive
Description Convert a char to an integer. You can assume the char is in ASCII code (See Definition, ...
- SD--批量删除订单
SD--批量删除订单 在sap应用中常常会需要批量删除一些错误录入的单据,为此开发了一个小程序.该程序为了安全,程序做了一下控制 1.限制用户只能删除自己的订单,不能删除别人输入的订单,如果需要修改一 ...
- Java只给汉字转URLEncoder
public static String encode(String str, String charset) throws UnsupportedEncodingException { Patter ...