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の間違いを引き起こします)ので、これは問題ではないと思います。
アプリの残りの部分はvirtualenvディレクトリにあるため、wsgiの「アプリケーション」ファイルについて言及する必要があります。
私はApacheがあまり得意ではないので(本番サーバーはリバースプロキシとネイティブPythonサーバーを使用するチェロキーであり、mod_wsgiは使用していません)、基本的なものが不足している可能性があります
基本的なbottle.pyは、wsgiハンドルを使用せずに直接実行すると実行されます。
使用: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