Created
July 26, 2013 00:55
-
-
Save iandexter/6085186 to your computer and use it in GitHub Desktop.
Using Flask in a virtual env on Python 2.6 mod_wsgi on RHEL 5.7. python26-mod_wsgi is part of EPEL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import site | |
import logging | |
site.addsitedir('/path/to/venv/lib/python2.6/site-packages') | |
sys.path.append('/path/to/venv') | |
sys.path.append('/path/to/venv/appname') | |
activate_this = '/path/to/venv/bin/activate_this.py' | |
execfile(activate_this, dict(__file__=activate_this)) | |
from appname import app as application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Directory structure: | |
/path/to/venv/ | |
lib/python2.6/site-packages/ | |
bin/activate_this.py | |
appname.wsgi | |
appname/ | |
__init__.py | |
[other modules for appname] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Location: /etc/httpd/conf.d/python26-mod_wsgi.conf | |
################################################################################# | |
# mod_python and mod_wsgi compatibility note | |
################################################################################# | |
# mod_wsgi will deadlock if run in daemon mode while mod_python is enabled | |
# do not enable both mod_python and mod_wsgi if you are going to use the | |
# WSGIDaemonProcess directive | |
# In previous version of mod_wsgi, apache would segfault when both mod_wsgi | |
# and mod_python were enabled. This update does not guarantee that will not | |
# happen. | |
# | |
################################################################################# | |
# Do not enable mod_python and mod_wsgi in the same apache process. | |
################################################################################# | |
# | |
# NOTE: By default python26-mod_python with not load if mod_wsgi is installed | |
# and enabled. Only load if mod_python and mod_wsgi are not already loaded. | |
<IfModule !python_module> | |
<IfModule !wsgi_module> | |
LoadModule wsgi_module modules/python26-mod_wsgi.so | |
WSGISocketPrefix /path/to/appname_root/ ### Should be owned by apache:apache | |
</IfModule> | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Location: /etc/httpd/vhosts.d/vhost.conf | |
<VirtualHost vhost.company.com:80> | |
ServerAdmin [email protected] | |
ServerName vhost.company.com | |
ServerAlias vhost | |
WSGIDaemonProcess appname user=app_user group=app_group threads=5 | |
WSGIScriptAlias / /path/to/venv/appname.wsgi | |
<Directory /path/to/appname_root/> | |
WSGIProcessGroup appname | |
WSGIApplicationGroup %{GLOBAL} | |
Order deny,allow | |
Allow from all | |
</Directory> | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment