【发布时间】:2017-06-17 10:29:28
【问题描述】:
我正在尝试在网络机器的端口上运行一个非常简单的烧瓶应用程序。我当前的服务器代码如下所示:
from flask import Flask
import json
app = Flask(__name__)
@app.route('/my_route')
def my_route():
return json.dumps({'data': 'this is an example'})
假设我网络上机器的 IP 是123.123.123.123,我想在端口5000 上运行我的应用程序。我希望能够在浏览器中导航或向123.123.123.123:5000/my_route 发出简单的HTTP 请求并获得JSON 响应。
我尝试关注mod_wsgi Flask documentation 未成功。在使用这样的指令编辑httpd.conf 后,我收到了500 Internal Server 错误显示:
Listen 5000
NameVirtualHost *:5000
<VirtualHost *:5000>
ServerName gcr_app
WSGIDaemonProcess gcr_app user=apache threads=5
WSGIScriptAlias / /var/www/gcr_app/gcr_app.wsgi
<Directory /var/www/gcr_app>
WSGIProcessGroup gcr_app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
并重新启动httpd 服务。
我在这里做错了什么?其他信息:
- RHEL 6.7
- Python 3.4.4
- 烧瓶 0.12
Apache 版本:
$ /usr/sbin/httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Feb 4 2016 08:22:15
如果我能提供其他有用的信息,请告诉我。
错误日志信息
[Mon Jan 30 17:55:22 2017] [error] [client x.x.x.x] (13)Permission denied: mod_wsgi (pid=2118): Unable to connect to WSGI daemon process 'gcr_app' on '/etc/httpd/logs/wsgi.2109.0.1.sock' after multiple attempts.
[Mon Jan 30 17:55:26 2017] [error] [client x.x.x.x] (13)Permission denied: mod_wsgi (pid=2114): Unable to connect to WSGI daemon process 'gcr_app' on '/etc/httpd/logs/wsgi.2109.0.1.sock' after multiple attempts.
[Mon Jan 30 17:55:27 2017] [error] [client x.x.x.x] (13)Permission denied: mod_wsgi (pid=2115): Unable to connect to WSGI daemon process 'gcr_app' on '/etc/httpd/logs/wsgi.2109.0.1.sock' after multiple attempts.
[Mon Jan 30 17:55:46 2017] [error] [client x.x.x.x] (13)Permission denied: mod_wsgi (pid=2113): Unable to connect to WSGI daemon process 'gcr_app' on '/etc/httpd/logs/wsgi.2109.0.1.sock' after multiple attempts.
[Mon Jan 30 17:57:48 2017] [error] [client x.x.x.x] File does not exist: /var/www/html/gcr_distance
[Mon Jan 30 17:57:48 2017] [error] [client x.x.x.x] File does not exist: /var/www/html/favicon.ico, referer: http://x.x.x.x/my_route
[Mon Jan 30 18:43:49 2017] [error] [client x.x.x.x] (13)Permission denied: mod_wsgi (pid=2116): Unable to connect to WSGI daemon process 'gcr_app' on '/etc/httpd/logs/wsgi.2109.0.1.sock' after multiple attempts.
谢谢
【问题讨论】:
-
您应该将您看到的错误发布在
/var/log/httpd/* -
看看它们,看看有没有什么重要的东西
-
您运行的是 Apache 2.2 还是 Apache 2.4?您的配置适用于 2.2,这与 RHEL 6.7 一致,但如果您已升级到 Apache 2.4,则可能会出现不同的配置格式导致权限错误。
-
apache是不是错误的用户?我只是尝试与我自己的用户一起做,但也没有用。 -
Apache主要以用户www_data运行