在工作中的服务器上(Apache 2.2.3),我试图用Flask激活我的第一个Hello World。我无法在任何典型的推荐位置找到错误日志。
我在/home/nrDee/public_html/rrfexpire
这是我的rrfexpire.wsgi脚本:
activate_this =
'/home/nrDee/public_html/rrfexpire/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
from rrfexpire import app as application
这已添加到Apache httpd.conf:
WSGIDaemonProcess rrfexipre user=apache group=apache threads=5
WSGIScriptAlias /blog /home/nrDee/public_html/rrfexpire/rrfexpire.wsgi
<Directory /home/nrDee/public_html/rrfexpire>
WSGIProcessGroup rrfexpire
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
这是我的Hello World测试(rrfexpire.py):
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def hello_world():
return "Hello, World!"
print hello_world()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8082, debug=True)
当我在http://departmentServer.company.com/rrfexpire/使用Chrome浏览器时,我希望看到结果,但我什么都没得到。整个nrDee目录设置为777权限,以消除阻止其运行的权限。我试图确认Python版本(2.7.13)和mod_wsgi与命令的兼容性
#ldd venv/lib/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so
该结果中的一行读取&#34; libpython2.7.so.1.0 =&gt; /usr/local/bin/anaconda/lib/libpython2.7.so.1.0" ;,我解释为mod_wsgi是为Python2.7正确编译的
我是新手,并且大量使用Flask和mod_wsgi文档,感觉卡住了。
您能否提供下一步检查的指导?
谢谢!
-nrDee
答案 0 :(得分:0)
我有一个有效的解决方案,但它并不完美,因为除非重新启动httpd服务,否则我的URL不会更新。但至少我现在可以看到我的HelloWorld!
我当前的rrfexpire.wsgi脚本让我感到困惑,因为它在py2.7 virtualenv中使用了Python3语法:
activate_this =
'/home/nrDee/public_html/rrfexpire/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
import sys
sys.path.insert(0, '/home/nrDee/public_html/rrfexpire')
from rrfexpire import app as application
这是我的httpd.conf
<VirtualHost *>
ServerName company.server.com:80
WSGIDaemonProcess rrfexpire user=apache group=apache
WSGIScriptAlias /rrfexpire /home/nrDee/public_html/rrfexpire/rrfexpire.wsgi
<Directory /home/nrDee/public_html/rrfexpire>
WSGIProcessGroup rrfexpire
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
</VirtualHost>