在Amazon linux上编写mod-wsgi脚本

时间:2016-08-29 07:29:14

标签: mod-wsgi httpd.conf

我正在使用 Plus.PeopleApi.loadVisible(mGoogleApiClient, null ).setResultCallback(new ResultCallbacks<People.LoadPeopleResult>() { @Override public void onSuccess(@NonNull People.LoadPeopleResult loadPeopleResult) { int personCount = loadPeopleResult.getPersonBuffer().getCount(); Log.d("fasfafasfsafasfas", "onSuccess: " + personCount); for (int i = 0; i < personCount; i++) { Person eachPerson = loadPeopleResult.getPersonBuffer().get(i); Log.d("fasfafasfsafasfas", "onSuccess: " + eachPerson.getImage().getUrl()); } } @Override public void onFailure(@NonNull Status status) { if (status.hasResolution()) { try { status.startResolutionForResult(activity, requestCode); } catch (IntentSender.SendIntentException e) { mGoogleApiClient.connect(); } } Log.d("fasfafasfsafasfas", "onFailure: " + status); } }); 并在Amazon linux上安装httpd2.4

我的mod-wsgi脚本如下所示:

/projects/mv2/test/test.wsgi

wsgi

/projects/mv2/test/test.py

import sys
import os

sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))

from test import *

Apache conf文件

from flask import Flask
app = Flask(__name__)

@app.route('/test')
def hello_world():
    return 'Hello, World!'

当我点击网址<VirtualHost *:80> ServerName test-algo.com WSGIDaemonProcess algos_app user=mv2 group=mv2 threads=1 WSGIScriptAlias / /projects/mv2/test/test.wsgi <Directory /projects/mv2/test/test> WSGIProcessGroup algos_app WSGIApplicationGroup %{GLOBAL} Options MultiViews FollowSymLinks AllowOverride all Require all granted </Directory> </VirtualHost> 时,我得到403响应,接下来是http://test-algo.com/test

httpd error file

我无法找到[authz_core:error] [pid 27555] [client 153.156.225.142:65083] AH01630: client denied by server configuration: /projects/mv2/test/test.wgi 脚本的错误。

1 个答案:

答案 0 :(得分:1)

Directory博客应该以:

开头
<Directory /projects/mv2/test>

路径末尾有一个额外的test

这会导致403错误。

WSGI脚本也应该使用:

from test import app as application

您的Flask文件使用的WSGI入口点的名称应为application而不是app

如果不解决此问题,您将在修复第一个错误后收到其他错误。