V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ri0day
V2EX  ›  Python

python uwsgi 部署问题

  •  
  •   ri0day ·
    ri0day · 2011-09-19 13:25:08 +08:00 · 6298 次点击
    这是一个创建于 4575 天前的主题,其中的信息可能已经有所发展或是发生改变。
    根据uwsgi的官方文档。我安装了uwsgi,结果是uwsgi这个工具安装好了。但是python里的模块没有。当我import uwsgi时报错说没有这个模块。我不知道这是什么问题。我的安装方法如下: easy_install-2.6 uwsgi
    但是结果说没有这个模块:
    [root@host93-16 uwsgi-0.9.9.2]# python
    Python 2.6 (r26:66714, Dec 15 2010, 17:34:26)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    import uwsgi
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named uwsgi

    奇怪的是我的uwsgi 这个命令是安装好的。安装过程中也没有任何报错.

    后来我根据官方文档里的quickstart()写了个测试的代码: pys.py

    def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"
    然后用 uwsgi -p 8 --gid www --uid www -s 127.0.0.1:8015 --wsgi-file /tmp/pys.py 起来进程
    但是nginx还是不能访问。

    nginx 配置很简单:

    location / {
    uwsgi_pass 127.0.0.1:8015;
    include uwsgi_params;
    }
    有人指点下。到底要怎么弄么。网上文章都是写和django结合的。我不想用框架。想自己写脚本实现。谢谢
    6 条回复    1970-01-01 08:00:00 +08:00
    linnchord
        1
    linnchord  
       2011-09-19 14:24:24 +08:00
    细节不清楚……有任何问题可查看uwsgi的log,应该有错误记录。
    bhuztez
        2
    bhuztez  
       2011-09-19 14:25:59 +08:00
    uwsgi就是 import 不了的
    linnchord
        3
    linnchord  
       2011-09-19 14:32:13 +08:00
    我还真没有试过import uwsgi,那是C写的吧?wsgi只是一个规范,uwsgi是实现这个规范的一个服务器,他运行以后会按照规范对你提供的程序进行调用,应该只有当运行在wsgi服务下时才能import,直接在shell或其他进程下是无法import的。
    mywaiting
        4
    mywaiting  
       2011-09-19 14:36:37 +08:00
    楼猪看看这个吧 http://obmem.info/?p=703 传送门
    est
        5
    est  
       2011-09-19 14:45:46 +08:00
    uwsgi不是用来import的
    ri0day
        6
    ri0day  
    OP
       2011-09-19 15:09:51 +08:00
    thanks all ,现在以及好了。其实不是什么配置问题。我nginx每次改完配置文件都是reload的,这次我stop 然后start ,成功了。

    代码如下:
    start_response('200 OK', [('Content-Type','text/html')])
    yield '<h1>FastCGI Environment</h1>'
    yield '<table>'
    for k, v in sorted(env.items()):
    yield '<tr><th>%s</th><td>%s</td></tr>' %(k,v)
    yield '</table>'
    yield '<h1>bye</h1>'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2891 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:56 · PVG 21:56 · LAX 06:56 · JFK 09:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.