0

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

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>
gromiczek
  • 2,970
  • 5
  • 28
  • 49
  • Is there anything in the Apache error and access logs to suggest the request is even getting to it? WebFaction uses a proxy in front, it is possible the proxy isn't even set up correctly so the request gets to Apache. – Graham Dumpleton Jun 18 '18 at 23:55
  • Most of the time problems with python apps on shared hosting are caused by WSGI configs. I'd advise you to create single file Flask app and make it working to understand how WSGI config works on your particular hosting. Then add venv, multi-file, different folder structures etc. [This seems like a must to know.](https://docs.webfaction.com/software/mod-wsgi.html) – Fine Jun 19 '18 at 08:09
  • @GrahamDumpleton - Thanks for your feedback - there are no logs yet, as it never gets up and running to make any. – gromiczek Jun 19 '18 at 12:53
  • @Fian - Yeah, I think that's what I need to do - just a basic Hello World to start and work up from there. Thanks! – gromiczek Jun 19 '18 at 12:54

0 Answers0