我已经按照“无法在 Webfaction 上部署简单的 Flask 应用程序”中的描述设置了一个示例测试应用程序,以运行一个基本的 web 应用程序。
以下是代码片段和结构:
“在网络派系服务器上”
/home/<user>/webapps
ls
>> testapp ( <-- my testapp)
cd testapp
>> apache2 htdocs
cd htdocs
>> index.py testapp.py
我存储在 htdocs 下的 index.py 文件如下:
import sys
testapp = "/home/<user>/webapps/testapp/htdocs"
if not testapp in sys.path:
sys.path.insert(0, testapp)
from testapp import app as application
我存储在 htdocs 下的 testapp.py 文件如下:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
我存储在 /home//webapps/testapp/apache2/conf 下的 httpd.conf 如下:
ServerRoot "/home/<user>/webapps/testapp/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User- Agent}i\"" combined
CustomLog /home/<user>/logs/user/access_testapp.log combined
DirectoryIndex index.py
DocumentRoot /home/<user>/webapps/testapp/htdocs
ErrorLog /home/<user>/logs/user/error_testapp.log
KeepAlive Off
Listen 24329
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess testapp processes=5 python-path=/home/<user>/webapps/testapp /lib/python3.1 threads=1
WSGIProcessGroup testapp
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIPythonPath /home/<user>/webapps/testapp/htdocs
WSGIScriptAlias / /home/<user>/webapps/testapp/htdocs/index.py
<Directory /home/<user>/webapps/testapp/htdocs>
AddHandler wsgi-script .py
ReWriteEngine on
RewriteBase /
WSGIScriptReloading On
</Directory>
我的域名指向了我在 webfaction 中的项目。默认 index.py 在我按照说明中的说明用新的覆盖之前工作。
以下是我在网络派系控制面板部分中的应用程序的详细信息:
testapp
Name testapp
Label mod_wsgi 3.4/Python 3.2
Machine
Web377
Description
mod_wsgi 3.4/Python 3.2
Port 24329
我检查了用户下的 error_testapp.log 并见下文:
[Mon Feb 04 07:45:05 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:45:10 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations
[Mon Feb 04 07:57:14 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:57:19 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations
尝试从 http:// <user>.webfactional.com/testapp/ 启动应用程序
我收到“站点未配置”消息。
有人可以说明这里可能出了什么问题。这是我第一次使用 Flask 和 webfaction。提前感谢您的时间。如果您需要更多详细信息,请告诉我。