I have been working on this for three days now and combing a variety of variously dated tutorials trying to get this to work, but each time I edit and refine, all I get is a 503 error (Service Temporarily Unavailable)
for the favicon.
I'm a noob to web app deployment, so bear with me. So far I know the critical pieces for deploying Flask on Webfaction are the index.py
file which makes portions of the site public, the httpd.conf
file to configure the Apache2 server, and I may need a .wsgi
file (for the Apache mod_wsgi module), but that piece remains unclear to me. Please note, I am using a virtualenv
instead of the lib
provided - the virtual env is up and running fine on Webfaction. The app runs fine locally, but I can't get the settings right on Webfaction. Here is what I have so far, for the record. Can you give me a nudge in the right direction? Thanks!
These are SO questions and other posts I've consulted (among many others) that were helpful but still didn't get this off the ground.
Python 2.7, Flask 0.10
Here is my app's file structure on Webfaction:
- myproject
- myproject_core
- myproject.wsgi (unsure how to use this)
- venv
- app
- run.py
- (other program-related python files)
- apache2
- httpd.conf
- (+ other standard contents included by Webfaction)
- lib (this is unused, as I have a virtualenv)
- htdocs
- index.py
- myproject_core
index.py:
import sys
yourappname = "/home/me/webapps/myproject/htdocs"
if not yourappname in sys.path:
sys.path.insert(0, yourappname)
from myproject import app as application
httpd.conf: (I admit I've mangled this so much there may now be too many or too few pieces...or both)
ServerRoot "/home/me/webapps/myproject/apache2"
LoadModule authz_core_module modules/mod_authz_core.so
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
LoadModule unixd_module modules/mod_unixd.so
LoadModule alias_module modules/mod_alias.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/me/logs/user/access_myproject.log combined
ErrorLog /home/me/logs/user/error_myproject.log
DirectoryIndex index.py
DocumentRoot /home/me/webapps/myproject/htdocs
Listen 30017
KeepAlive Off
SetEnvIf X-Forwarded-SSL on HTTPS=1
ServerLimit 1
StartServers 1
MaxRequestWorkers 5
MinSpareThreads 1
MaxSpareThreads 3
ThreadsPerChild 5
WSGIDaemonProcess project processes=2 threads=12 python-home=/home/me/webapps/myproject/myproject_core/venv/
WSGIProcessGroup project
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /home/me/webapps/myproject/htdocs/index.py
<Directory /home/me/webapps/myproject/htdocs/>
AddHandler wsgi-script .py
RewriteEngine on
RewriteBase /
WSGIScriptReloading On
</Directory>