I'm trying to deploy a flask application with Apache and mod_wsgi.
I followed the instructions on the official flask documentation.
I installed Apache and mod_wsgi (that I'm not really sure it's installed for python 3.5, but I can't find any way to check).
I created a virtual environment for my application myapp with all the necessary dependencies installed (using pip).
virtualenv -p python3 env
I created a myapp.wsgi file as suggested in the previous link:
activate_this = '/var/www/myapp/env/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
from project import app as application
I created a vhost for my application
<VirtualHost *:80>
ServerName myapp.com
WSGIScriptAlias / /var/www/myapp/myapp.wsgi
<Directory /var/www/myapp>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When I try to access my application with the browser I get a 500 error and the logs error
[...] from project import app as application
[...] ImportError: No module named project
I think there is a problem where I activate the virtual environment.
Any idea to fix the situation?