简体   繁体   English

配置 wsgi python

[英]configure wsgi python

im configuring my EC2 instance (amazon web services) on an ubuntu server, to test django(python)我在 ubuntu 服务器上配置我的 EC2 实例(亚马逊 web 服务),以测试 django(python)

I have python installed, and the apache server,我安装了 python 和 apache 服务器,

I have the It works!我有It works! [apache] page on my url address, index.html [apache]页面在我的url地址,index.html

now im configuring the wsgi and mod_wsgi [for python and django],现在我正在配置 wsgi 和 mod_wsgi [for python and django],

im following this info to configure wsgi:我正在按照此信息配置 wsgi:

deploy python wsgi app tutorial 部署 python wsgi 应用教程

but when I try the Basic Hello World WSGI Configuration但是当我尝试Basic Hello World WSGI Configuration

import os 
import sys 

sys.path.append('/srv/www/cucus/application') 

os.environ['PYTHON_EGG_CACHE'] = '/srv/www/cucus/.python-egg' 

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

and go to mysite/application/application.wsgi和 go 到 mysite/application/application.wsgi

http://ec2-107-20-20-19.compute-1.amazonaws.com/cucus/application/application.wsgi http://ec2-107-20-20-19.compute-1.amazonaws.com/cucus/application/application.wsgi

in my browser, i see the code for the page, but not the rendered "hello world"在我的浏览器中,我看到了页面的代码,但看不到呈现的“hello world”

what im i missing?我错过了什么?

do I need to configure the virtual hosts for ubuntu?, even im using just one site?我是否需要为 ubuntu 配置虚拟主机?即使我只使用一个站点?

thanks!谢谢!

You need your output to be binary.你需要你的 output 是二进制的。

Change改变

output = 'Hello World!'

to

output = b'Hello World!'

Here's some simple WSGI boilerplate code I created - show's you how to manage a GET and POST request.这是我创建的一些简单的 WSGI 样板代码 - 向您展示如何管理 GET 和 POST 请求。

https://github.com/blarking94/Python/blob/master/web_server_gateway_interface.py https://github.com/blarking94/Python/blob/master/web_server_gateway_interface.py

Have you read any of the actual mod_wsgi documentation or watch the presentation about it:您是否阅读过任何实际的 mod_wsgi 文档或观看过有关它的演示:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

You either never set up WSGIScriptAlias or didn't enable the site for Apache properly to read it or didn't restart Apache.您要么从未设置 WSGIScriptAlias,要么没有为 Apache 正确启用站点以读取它,或者没有重新启动 Apache。

Try restarting Apache if that does not work then double your apache config you are enabling mod_wsgi with this line of code LoadModule wsgi_module modules/mod_wsgi.so as well as WSGIScriptAlias / /path/to/mysite/apache/django.wsgi尝试重新启动 Apache 如果这不起作用然后将您的 apache 配置加倍 您正在使用这行代码启用 mod_wsgi LoadModule wsgi_module modules/mod_wsgi.so以及WSGIScriptAlias / /path/to/mysite/apache/django.wsgi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 django 多个站点 wsgi 就够了吗? - django multiple sites wsgi is enough? Django EC2 mod_wsgi 配置与 Apache 不工作 - Django EC2 mod_wsgi configuration with Apache not working 无法使用 mod_wsgi 的运行服务器访问 Bitnami Django web 应用程序 - Unable to access Bitnami Django web app using run server of mod_wsgi Flutterfire配置无法以任何可能的方式工作 - Flutterfire configure not working in any possible way 为 containerd CLI ctr 配置对 GCR 的访问 - Configure access to GCR for containerd CLI ctr 如何在 Flutter 中使用最新版本配置 Firebase Messaging? - How to configure Firebase Messaging with latest version in Flutter? 如何使用 aws 文档数据库配置 sorry cypress? - How to configure sorry cypress with aws document DB? 一个Firebase项目的规则怎么配置才安全? - How to configure the rules of a Firebase project to be safe? 如何在 cloudformation 堆栈中为 lambda 配置 asynconfig? - how to configure asynconfig for lambda in cloudformation stack? Flutterfire 配置意外字符(字符 1)错误 - Flutterfire configure Unexpected character (at character 1) error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM