我在应用程序帐户下有一个linux apache 2.4.12和mod_wsgi 4.5.2(mod_wsgi.so安装到apache中) . Apache在应用程序帐户下的端口8050下运行 . 在此链接下测试mod_wsgi工作:http://modwsgi.readthedocs.org/en/develop/user-guides/quick-configuration-guide.html#wsgi-application-script-file并输入了我的URL:http://mytest.mydomain.com:8050/myapp . 它显示"Hello World",因此它表明我的mod_wsgi安装正常 . 接下来我试着看看我是否可以使烧瓶应用工作 .
我在/ home / myuserId / wsgi下创建了简单的hello.py文件:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
然后我创建了一个简单的wsgi文件:
import sys, os
sys.path.insert(0, "/home/myuserId/wsgi")
from hello import app as application
然后我跟随其他建议,包括这个http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/,用virtualhost配置我的apache http.conf文件:
<VirtualHost *:8050>
# ServerName www.example.com
WSGIDaemonProcess hello user=appuser group=appuser threads=5
WSGIScriptAlias / /home/myuserId/wsgi/hello.wsgi
<Directory /home/myuserId/wsgi>
WSGIProcessGroup hello
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options +ExecCGI
AddHandler wsgi-script .wsgi
</Directory>
</VirtualHost>
我保存了httpd.conf文件并重新启动了apache w / o错误 . 当我在chrome:http://mytest.mydomain.com:8050/hello或http://mytest.mydomain.com:8050/hello_world中输入网址时,出现此错误:
**Not Found**
The requested URL /hello was not found on this server.
Apache/2.4.12 (Unix) mod_wsgi/4.5.2 Python/2.7.9 Server at mytest.mydomain.com port 8050.
我的问题是:
-
是我的配置错了?
-
上面的hello flask应用程序使用的URL是什么?
-
尝试
WSGIScriptAlias /hello /home/myuserId/wsgi/hello.wsgi
来挂载hello应用程序但是找不到 . -
for flask app,为什么conf文件必须在VirtualHost中配置应用程序?
1 回答
您没有使用主机名指定ServerName指令 . 因此,它将与VirtualHost不匹配,而是将回退到它在Apache配置文件中找到的第一个VirtualHost .