在使用FastCGI (Uberspace)将Flask应用程序部署到Apache服务器时,我遇到了一些问题。我的基本hello world应用程序正在运行。我为索引视图设置了一个变量。但是,变量上的机会不会更新浏览器中的视图。使用python geoflask.fcgi运行该进程将显示更新的版本(在终端中),但会显示以下警告:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK我使用的是一个virtualenv,我的文件如下所示:
我的fcgi-bin/geoflask.fcgi:
#!/home/usr/.virtualenvs/flaskenv/bin/python2.7
RELATIVE_WEB_URL_PATH = '/geoflask'
import os
LOCAL_APPLICATION_PATH = os.path.expanduser('~') + '/html/geoflask'
import sys
sys.path.insert(0, LOCAL_APPLICATION_PATH)
from flup.server.fcgi import WSGIServer
from app import app
class ScriptNamePatch(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
environ['SCRIPT_NAME'] = RELATIVE_WEB_URL_PATH
return self.app(environ, start_response)
app = ScriptNamePatch(app)
if __name__ == '__main__':
WSGIServer(app).run()我的.htacces:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files>
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /fcgi-bin/geoflask.fcgi/$1 [QSA,L]
</IfModule>有什么提示或建议吗?我整天都在和它作斗争...
发布于 2014-02-13 04:07:51
Apache不会立即重新加载FastCGI服务器进程。看看the docs for mod_fastcgi,mod_fastcgi似乎只支持重载after an idle period, after a certain number of requests, or after a certain period of time。这就是为什么您的应用程序似乎不会更新,即使当您从命令行运行它时,它也会更新。
为了获得你想要的行为(每次更改都会重新加载),你似乎需要将FcgidMaxRequestsPerProcess或FcgidCmdOptions MaxRequestsPerProcess设置为1(实质上是将你的FastCGI设置为CGI设置)。这将在每次请求时重新加载应用程序,因此它不应该用于生产-但它将使开发更容易。
https://stackoverflow.com/questions/21702918
复制相似问题