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部署模式的可以参考另 ...
随机推荐
- 第一次参加acm区域赛
什么,这周天就要去参加acm焦作赛,简直不敢相信.从大一暑假七月份中旬到今天十一月23日,加入acm将近四个多月的时间,如今到了检验自己的时候了.aaaaaaaaaa.乌拉,必胜.打印个模板,在跑个步 ...
- Restful framework【第七篇】权限组件
基本使用 -写一个类: class MyPer(BasePermission): message='您没有权限' def has_permission(self, request, view): # ...
- cannot open window service on computer '.' in window application
1.配置错误,需要检查对应的windows service的exe文件所在文件夹下的log 2.在命令行通过Start-Service启动,需要有管理员权限.
- 论文笔记之:Semi-supervised Classification with Graph Convolutional Networks
Semi-supervised Classification with Graph Convolutional Networks 2018-01-16 22:33:36 1. 文章主要思想: 2. ...
- 转载:避免重复插入,更新的sql
本文章来给大家提供三种在mysql中避免重复插入记录方法,主要是讲到了ignore,Replace,ON DUPLICATE KEY UPDATE三种方法,各位同学可尝试参考. 案一:使用ignore ...
- error: pcap library not found! 解决方法
参考: error: pcap library not found! error: pcap library not found! 解决方法 $ sudo apt-get install libsql ...
- JavaScript重点知识(二)
三.JS的API 3.1知识点(DOM) 1)DOM本质 将html结构化成浏览器和JS可识别可操作的东西 2)变量计算---强制类型转换 获取DOM节点 Attribute(对html标签属性的修改 ...
- unity 截图 压缩 处理
/****************************************************** unity屏幕截图,并转换成Base64码* 作者: lyb* 日期:2017年7月25 ...
- 【BZOJ】4008: [HNOI2015]亚瑟王
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4008 这题主要在于:先算概率,再算期望! 一轮一轮的计算似乎很复杂,每一轮它其实是可以看作 ...
- Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图
E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard in ...