【发布时间】:2016-11-18 15:52:41
【问题描述】:
我正在使用一个使用 apache 2.4 的共享主机帐户,尝试使用 http://fgimian.github.io/blog/2014/02/14/serving-a-python-flask-website-on-hostmonster 部署一个烧瓶应用程序。我已经把代码和 fcgi 脚本放在 public_html 文件夹中了,文件夹的内容在上面的截图中:
manage_apache.fcgi 脚本是:
#!/home/username/anaconda2/bin/python
import sys,os
from flup.server.fcgi import WSGIServer
sys.path.insert(0, '/home/username/public_html')
from myflaskapp.settings import Config, SharedConfig
from myflaskapp.app import create_app
if __name__ == '__main__':
app = create_app(SharedConfig)
WSGIServer(app).run()
我已经到了最后一步,并在命令行中使用 putty to SSH in 进行测试:
[~/public_html]# ./manage_apache.fcgi
我可以看到正在生成的正确网页,所以我假设我的主机支持快速 cgi。我没有收到任何 python 错误。
文章中的.htaccess文件是:
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ manage_apache.fcgi/$1 [QSA,L]
在浏览器中当我浏览 mysite.org 时,我得到了
Not Found
The requested URL /manage_apache.fcgi/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
根据支持 .htaccess 文件正在重定向到 manage_apache.fcgi/$1
-rwxr-xr-x 1 myusername myusername Nov 22 17:26 manage_apache.fcgi*
我该如何解决这个问题?
【问题讨论】:
标签: python apache .htaccess flask