I'm using a raspberry pi with debian linux mod_wsgi and flask. I used this tutorial to set everything up and the python script will run if I run the command
python myFile.py
However, when I try to run it from apache I get an HTTP 500 error.
This is my wsgi file:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,'/var/www/FlaskApp/')
from FlaskApp import app as application
this is my .conf file:
<VirtualHost *:80>
ServerName (my-server-ip)
ServerAdmin (my-Email)
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
these are the permissions on the wsgi file
-rw-r--r-- 1 root root 211 Jul 30 18:51 flaskapp.wsgi
I've looked at many different tutorials but have yet to find a solution...
I am sure that I am not running a virtual environment for my python file and know that that could be an issue but am unsure how to solve that. Thanks for the help in advance.
this is the error that Im getting:
[Mon Jul 31 17:09:29.367693 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] mod_wsgi (pid=2921): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module.
[Mon Jul 31 17:09:29.367924 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] mod_wsgi (pid=2921): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
[Mon Jul 31 17:09:29.368074 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] Traceback (most recent call last):
[Mon Jul 31 17:09:29.368221 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] File "/var/www/FlaskApp/flaskapp.wsgi", line 8, in <module>
[Mon Jul 31 17:09:29.368643 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] from FlaskApp import app as application
[Mon Jul 31 17:09:29.368793 2017] [wsgi:error] [pid 2921:tid 1971319856] [client :62373] ImportError: No module named FlaskApp
/var/www/FlaskAppand/var/www/FlaskApp/FlaskApp? What version of Python is mod_wsgi compiled for? What version of Python is your code meant to be written for?__init__.pyfile in/var/www/FlaskApp/FlaskApp. You need to have it if being run with Python 2. This is why asked what Python version code was set up for. Python 3 doesn't require that file. The difference between 2.7.8 and 2.7.9 doesn't matter.