你好在世界的mod_wsgi [英] Hello World in mod_wsgi

查看:241
本文介绍了你好在世界的mod_wsgi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的追求一再未能得到我的烧瓶应用程序中使用Apache的运行的mod_wsgi 我决定尝试运行的 Hello World示例。下面是我 -

After failing repeatedly in my quest to get my flask application to run on Apache using mod_wsgi I decided to try running the hello world example. Here is what I have -

目录结构(我改变了Apache默认的 /无功/网络〜/的public_html

Directory Structure (I changed the apache default /var/www to ~/public_html)

- public_html    
   - wsgi-scripts
      - test_wsgi.wsgi
   - test_wsgi
      - test_wsgi.wsgi

test_wsgi.wsgi文件

test_wsgi.wsgi file

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]

虚拟主机配置文件(称为testwsgi) - 这个位于的/ etc /启用站点-的Apache2 / /

<VirtualHost *:80>
    DocumentRoot ~/public_html/test_wsgi

    <Directory ~/public_html/test_wsgi>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias /wsgi ~/public_html/wsgi-scripts/test_wsgi.wsgi

    <Directory ~/public_html/wsgi-scripts>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

当我尝试将本地主机/ WSGI 在浏览器上,我得到一个404 Not Found错误。我究竟做错了什么?这是我第一次尝试部署在生产服务器上的应用程序。到现在为止我花了使用谷歌应用程序引擎的简单方法。我不能继续我的部署应用程序烧瓶直到启动并运行。非常感谢!

When I try going to localhost/wsgi on the browser I get a 404 Not Found error. What am I doing wrong? This is the first time I'm trying to deploy an app on a production server. Until now I took the easy way of using Google App Engine. I cant proceed to deploy my flask app until this is up and running. Thanks a lot!

推荐答案

您需要使用绝对路径,即不使用。这工作得很好,我...

You need to use an absolute path, i.e. don't use ~. This works fine for me...

[mpenning@tsunami public_html]$ sudo cat /etc/apache2/sites-available/wsgi_test
<VirtualHost *:80>
    ServerName wsgihost
    DocumentRoot /home/mpenning/public_html
    WSGIScriptAlias / /home/mpenning/public_html/test.wsgi
</VirtualHost>
[mpenning@tsunami public_html]$

首先,我成立了 / etc / hosts中,所以我可以保证我可以在查询的主机名混流...

First I set up a hostname in /etc/hosts, so I could ensure that I can mux on the hostname in the query...

[mpenning@tsunami public_html]$ grep wsgihost /etc/hosts
127.0.1.1       tsunami.foo.net  tsunami wsgihost
[mpenning@tsunami public_html]$

重新启动Apache,并出具wget的......

Restart apache, and issue a wget...

[mpenning@tsunami public_html]$ wget http://wsgihost/
--2012-08-29 05:50:26--  http://wsgihost/
Resolving wsgihost... 127.0.1.1
Connecting to wsgihost|127.0.1.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12 [text/plain]
Saving to: âindex.html.3â

100%[======================================>] 12          --.-K/s   in 0s

2012-08-29 05:50:26 (1.48 MB/s) - âindex.html.3â

[mpenning@tsunami public_html]$ cat index.html
Hello World![mpenning@tsunami public_html]$ #  <------

这篇关于你好在世界的mod_wsgi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆