In CentOS 6.4, I created python virtual environment in /var/www/html/venv folder. Then after activating the virtual environment, I installed all necessary python libraries for my flask application. I checked, that Flask libraries were in /var/www/html/venv/lib/python2.7/site-packages folder. I've already installed and loaded mod_wsgi. Now in my flask app, which is in /var/www/html/truckman/wsgi folder, I created truckman.wsgi file with the following content:
activate_this = '/var/www/html/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/var/www/html/truckman/wsgi/')
from app import app as application
import config
application.config.from_object(config.Dev)
Also, in /etc/httpd/conf/httpd.conf I added:
<VirtualHost *>
WSGIScriptAlias / /var/www/html/truckman/wsgi/truckman.wsgi
<Directory /var/www/html/truckman/wsgi>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Now, in /var/www/html/truckman/wsgi folder, I created run.py file with the following content:
from app import app as application
import config
application.config.from_object(config.Dev)
if __name__ == "__main__":
application.run(port=5001)
Now I tested my app with flask's development server; if I execute "python run.py", my app works as expected. I can browse to localhost:5001, and the app's initial page shows up.
Then I tested my app with mod_wsgi: First killed run.py process, and restarted httpd service, and after that browsed to localhost; but it returned: "500 Internal Server Error". In /etc/httpd/logs/error_log file I found the following error message: "ImportError: No module named flask". What's wrong with my settings?