1

为了调试一个bottle.py应用程序,我正在尝试部署到openshift(我怀疑有一个问题连接到了mod_wsgi - 这个开放的问题)我正在尝试在我的linux站上运行mod_wsgi。正如标题所述 - 我失败得很惨。

我根据mod_wsgi wiki中的说明下载并安装了编译成python2.6的mod_wsgi。

运行 apache2ctl -MI 验证 mod_wsgi(shared) 在结果列表中,所以我想我已经得到了正确的部分

我在 /etc/apache2/sites-availble 中写了一个appname文件,其中包含:

<VirtualHost *:8051> #also tried with * or *:80 or myappname
#   ServerName 127.0.0.1:8051 #also tried to uncomment
    ServerAlias wikimen #also tried without

#   WSGIDaemonProcess wikimen user=myusername group=myusername threads=5 #also tried to uncomment
   WSGIScriptAlias / /home/myusername/workspace/myapp/wsgi/application
   DocumentRoot /home/myusername/workspace/myapp/wsgi

    <Directory /home/myusername/workspace/myapp/wsgi>

#        WSGIProcessGroup myapp
#       WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

并在运行后:

sudo a2ensite

检查它是否在启用站点的目录中相应地创建并运行:

sudo service apacha2 reload

当我转到浏览器并尝试: localhost:8051 或 localhost/appname/routename 或 localhost:8051/routename 或 localhost:8051/appname 或它们之间的任何其他组合时,我只是得到(也将 localhost 更改为 127.0.0.1 时):

unable to connect

wsgi 句柄文件(名为“应用程序”)包含:

#!/usr/bin/python

import os
here = os.path.dirname(os.path.abspath(__file__))


try:

    os.environ['PYTHON_EGG_CACHE'] = os.path.join(os.environ['OPENSHIFT_APP_DIR'],'virtenv/lib/python2.6/site-packages')

except:
    os.environ['PYTHON_EGG_CACHE'] = os.path.join(here,'..','data/virtenv/lib/python2.6/site-packages')

print ('python egg cache set to: %s' % os.environ['PYTHON_EGG_CACHE'])
try:

    virtualenv = os.path.join(os.environ['OPENSHIFT_APP_DIR'],"virtenv/bin/activate_this.py")
except:
    virtualenv = os.path.join(here,'..',"data/virtenv/bin/activate_this.py")

print ('virtualenv is in:%s' % virtualenv)
try:
    execfile(virtualenv, dict(__file__=virtualenv))
    print ('executed')

except IOError:
    pass

from myappname import application

但正如我所说它在openshift服务器中确实有效(也调用了一些奇怪的bottle.py错误)所以我想这不是问题我也很高兴被驳斥

也许我应该提到 wsgi“应用程序”文件,因为应用程序的其余部分位于 virtualenv 目录中

我不太擅长 apache(我们的生产服务器是 cherokee,使用反向代理和本机 python 服务器,而不是 mod_wsgi)所以也许我缺少一些基本的东西

如果我直接使用wsgi句柄运行基本的bottle.py,我会很高兴有任何帮助

使用:ubunto 11,apache2.2,当前 mod_wsgi 版本,python 2.6(我也有 python 2.7,但根据 openshift 服务器,该应用程序在 python2.6 的 virtualenv 中运行)

跟踪 apache2 错误日志并没有显示任何有用的信息(也杀死它并重新开始):

> [Sat Mar 24 15:45:10 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sat Mar 24 21:19:24 2012]
> [notice] caught SIGTERM, shutting down [Sat Mar 24 21:19:54 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sat Mar 24 21:36:30 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sat Mar 24 21:40:48 2012]
> [notice] caught SIGTERM, shutting down [Sat Mar 24 21:41:18 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sat Mar 24 23:47:11 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sun Mar 25 22:20:22 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sun Mar 25 22:34:12 2012] [notice] caught SIGTERM,
> shutting down [Sun Mar 25 22:34:24 2012] [notice] Apache/2.2.20
> (Ubuntu) PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3
> Python/2.6.7 configured -- resuming normal operations
4

1 回答 1

1

我在浏览器中出现“无法连接”,然后与 mod_wsgi 无关,而是您的浏览器甚至无法连接到服务器。用您在 Apache 错误日志中找到的任何错误消息修改您的问题?由于配置文件错误,您的 Apache 甚至可能无法启动。

于 2012-03-25T00:44:04.460 回答