dimanche 24 mai 2015

How can I successfully deploy a Flask App to an Apache Web Server?

I'm trying to deploy my flask application but I'm running into issues with the deployment. Based on my review of the error logs, the issue seems to stem from the import of my application per my WSGI file.

Error Logs: 
 [Sun May 24 14:01:56.504439 2015] [:info] [pid 15794:tid 140205881620224]                           
 [client 50.200.43.210:50055] mod_wsgi (pid=15794, process='',         
 application='ec2-50-55-234-76.us-west-2.compute.amazonaws.com|'): Loading     
 WSGI script '/var/www/Testme/Testme.wsgi'.
 [Sun May 24 14:01:56.504645 2015] [:error] [pid 15794:tid 140205881620224]     
 [client 50.200.43.210:50055] mod_wsgi (pid=15794): Target WSGI script     
 '/var/www/Testme/Testme.wsgi' cannot be loaded as Python module.
 [Sun May 24 14:01:56.504655 2015] [:error] [pid 15794:tid 140205881620224]   
 [client 50.200.43.210:50055] mod_wsgi (pid=15794): Exception occurred         
 processing WSGI script '/var/www/foodie/foodie.wsgi'.
 [Sun May 24 14:01:56.504668 2015] [:error] [pid 15794:tid 140205881620224]  
 [client 50.200.43.210:50055] Traceback (most recent call last):
 [Sun May 24 14:01:56.504697 2015] [:error] [pid 15794:tid 140205881620224]   
 [client 50.200.43.210:50055]   File "/var/www/Testme/Testme.wsgi", line 4,   
 in <module>
 [Sun May 24 14:01:56.504758 2015] [:error] [pid 15794:tid 140205881620224]   
 [client 50.200.43.210:50055]     from Testme import Testme as application
 [Sun May 24 14:01:56.504774 2015] [:error] [pid 15794:tid 140205881620224]   
 [client 50.200.43.210:50055] ImportError: No module named Testme

 App Directory Structure:

/var/www/Testme:
   /Testme #The Flask App
     /app
        app.py
        search_results.py
        yelp.py
       /static
       /templates
       /Logs
     /bin
     /lib
     /venv
     pip-selfcheck.json
   Testme.wsgi
WGSI File : /var/www/Testme/Testme.wsgi
import sys
sys.path.insert(0, '/var/www/Testme/Testme')
from Testme import Testme as application

Apache2 Conf File : Testme.conf

<VirtualHost *:80>
        ServerName ec2-52-24-234-73.us-west-2.compute.amazonaws.com
         WSGIDaemonProcess foodie
      WSGIScriptAlias / /var/www/Testme/Testme.wsgi
      <Directory /var/www/Testme>
            WSGIProcessGroup Testme
         WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     LogLevel info
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>




Aucun commentaire:

Enregistrer un commentaire