微信公众账号开发者认证:uwsgi结合web.py的步骤详解

Linux Version:

[root@mail ~]# uname -a
Linux mail.vtata.cn 2.6.18-128.el5xen #1 SMP Wed Jan 21 11:12:42 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@mail ~]# cat /etc/redhat-release
CentOS release 5.3 (Final)

Python Version:

[root@mail ~]# python
Python 2.7.5 (default, Jun 14 2013, 18:21:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type help, copyright, credits or license for more information

uwsgi Version:

uWSGI 1.4.9

web.py Version:

web.py-0.37

首先是安装所需程序,因为Centos自带的Python是2.4,如果不更新至2.7会发生模块导入错误等问题,

tar xvf Python-2.7.5.tgz
cd Python-2.7.5
./configure && make all && make install && make distclean
mv /usr/bin/python /usr/bin/python.bak
ln -sv /usr/local/bin/python2.7 /usr/bin/python
sed -i s@/usr/bin/python@/usr/bin/python2.4@ /usr/bin/yum
tar zxvf uwsgi-1.4.9.tar.gz
cd uwsgi-1.4.9
python uwsgiconfig.py --build
python setup.py install
tar zxvf web.py-0.37.tar.gz
cd web.py-0.37
python setup.py install

本次是通过uwsgi与nginx结合进行使用,关于uwsgi与nginx整合请参加前一篇文章。

编写验证代码如下:

文件名:webinput.py

import web
import hashlib
urls = (
    '/','index'
)
class index:
    def GET(self):
        token='shiji'
        sign = web.input()
        tmplist = [token,sign.timestamp,sign.nonce]
        tmplist.sort()
        tmpstr = %s%s%s%tuple(tmplist)
        tmpstr = hashlib.sha1(tmpstr).hexdigest()
        if tmpstr == sign.signature:
            return sign.echostr
        else:
            return None
app = web.application(urls,globals())
application = app.wsgifunc()

启动nginx后启动uwsgi,启动过程如下:

[root@mail html]# uwsgi -s 127.0.0.1:9000 -w webinput
*** Starting uWSGI 1.4.9 (64bit) on [Mon Jun 17 17:19:16 2013] ***
compiled with version: 4.1.2 20080704 (Red Hat 4.1.2-44) on 17 June 2013 17:15:20
os: Linux-2.6.18-128.el5xen #1 SMP Wed Jan 21 11:12:42 EST 2009
nodename: mail.vtata.cn
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /usr/local/nginx/html
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 61234
your memory page size is 4096 bytes
detected max file descriptor number: 52100
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:9000 fd 3
Python version: 2.7.5 (default, Jun 14 2013, 18:21:34)  [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xfe30520
your server socket listen backlog is limited to 100 connections
mapped 72424 bytes (70 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xfe30520 pid: 10775 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 10775, cores: 1)
13712480011371460796shiji
[pid: 10775|app: 0|req: 1/1] 101.226.33.171 () {34 vars in 616 bytes} [Mon Jun 17 17:19:43 2013] GET /?signature=915c123b81282828ae1eecdc202336d07dfc15d8&echostr=5889465363321509055&timestamp=1371460796&nonce=1371248001 => generated 4 bytes in 2 msecs (HTTP/1.0 200) 0 headers in 19 bytes (2 switches on core 0)

打开微信公众平台界面,在高级功能里面进行设置如图:

微信公众账号开发者认证:uwsgi结合web.py的步骤详解

微信公众账号开发者认证:uwsgi结合web.py的步骤详解

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


网页授权获取用户信息的方法
报错config:invalid signature的解决方案
微信开发百思不得姐实战教程
详解微信开发input输入框
教你libco是如何支撑巨大数据信息量的
微信二次开发之文本消息请求与发送
微信开发H5轻游戏
scroll-view完成列表页的方法详解
Java微信开发之自定义菜单的创建
微信开发之input控件的实例详解
微信开发Emoji表情的实例教程
微信开发中详解textarea的使用方法
微信开发中使元素占满全屏的方法介绍
微信开发之数据访问的方法详解
微信二次开发之各类型消息封装
微信开发之数据库操作
如何获取微信好友的地理位置信息
分享3款微信开发开源框架
微信开发之获取服务器IP
微信开发之公交换乘功能代码详解