I have a django (1.7) app that works pretty well on a Centos7 server. Now i moving to production server RHEL 6 and still have some issues.
The problem is the mod_wsgi.
The server config:
RHEL6
Apache 2.2
Django 1.7
Python 2.6
the apache error log
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Target WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py' cannot be loaded as Python module.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Exception occurred processing WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py'.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] File "/home/evtdb/FLWeb/FLWeb/wsgi.py", line 21, in <module>
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] from django.core.wsgi import get_wsgi_application
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] ImportError: No module named django.core.wsgi
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Target WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py' cannot be loaded as Python module.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Exception occurred processing WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py'.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] File "/home/evtdb/FLWeb/FLWeb/wsgi.py", line 21, in <module>
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] from django.core.wsgi import get_wsgi_application
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] ImportError: No module named django.core.wsgi
the rest of the important files
flweb.conf
WSGIScriptAlias / /home/evtdb/FLWeb/FLWeb/wsgi.py
WSGIDaemonProcess localhost python-path=/home/evtdb/FLWeb:/usr/lib/python2.6/site-packages
WSGIProcessGroup localhost
<VirtualHost 127.0.0.1:8080>
<Directory /home/evtdb/FLWeb/FLWeb>
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
</VirtualHost>
wsgi.py
"""
WSGI config for FLWeb project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FLWeb.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
ldd modules/mod_wsgi.so
linux-vdso.so.1 => (0x00007fff6afff000)
libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00007fd69fc02000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd69f9e5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fd69f7e0000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007fd69f5dd000)
libm.so.6 => /lib64/libm.so.6 (0x00007fd69f359000)
libc.so.6 => /lib64/libc.so.6 (0x00007fd69efc4000)
/lib64/ld-linux-x86-64.so.2 (0x000000330aa00000)
I thought that a problem could be that mod_wsgi seems compiled with lib64, so I changed the python path on the flweb.conf to lib64 but it didn't worked
EDIT:
I realize the server has python 2.7 in /user/local/lib and that is the python version where django is installed. I changed the path in the conf file, but now I guess I need to rebuild the mod_wsgi
EDIT2:
Trying to rebuild mod_wsgi, have this problem
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
according to https://code.google.com/p/modwsgi/wiki/InstallationIssues is a conflict between python that was compiled to 32 bit and mod_wsgi to 64
Related
I have a simple flask app that i want to be accessible from internet.
OS is debian7, and unfortunately it can't be changed.
What I did:
- downloaded and installed Python3.4 into /usr/local/opt/python3.4.3
- installed wsgi lib for py3
- installed virtualenv and created new env in my flask project folder
- installed flask together with some other packages that I need within this env
- created VirtualHost as follows:
cat /etc/apache2/sites-available/Monitor
Listen 8080
<VirtualHost *:8080>
ServerName {ip address}
ServerAdmin {my email}
WSGIScriptAlias / /var/www/Monitor/monitor.wsgi
<Directory /var/www/Monitor/Monitor/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/Monitor/Monitor/static
<Directory /var/www/Monitor/Monitor/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
now when i try to access the app from the internet I see these errors in error.log
[Sat Nov 14 22:16:04 2015] [error] /usr/local/bin/python3
[Sat Nov 14 22:16:04 2015] [error] [client ip] mod_wsgi (pid=13450): Target WSGI script '/var/www/Monitor/monitor.wsgi' cannot be loaded as Python module.
[Sat Nov 14 22:16:04 2015] [error] [client ip] mod_wsgi (pid=13450): Exception occurred processing WSGI script '/var/www/Monitor/monitor.wsgi'.
[Sat Nov 14 22:16:04 2015] [error] [client ip] Traceback (most recent call last):
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/monitor.wsgi", line 21, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from Monitor import app as application
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/__init__.py", line 4, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from flask import Flask, render_template, url_for
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/flask/__init__.py", line 17, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] from werkzeug.exceptions import abort
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/werkzeug/__init__.py", line 152, in <module>
[Sat Nov 14 22:16:04 2015] [error] [client ip] __import__('werkzeug.exceptions')
[Sat Nov 14 22:16:04 2015] [error] [client ip] File "/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages/werkzeug/exceptions.py", line 113
[Sat Nov 14 22:16:04 2015] [error] [client ip] return u'<p>%s</p>' % escape(self.description)
[Sat Nov 14 22:16:04 2015] [error] [client ip] ^
[Sat Nov 14 22:16:04 2015] [error] [client ip] SyntaxError: invalid syntax
From what I could find in the internet, such errors appear when trying to start flask app with python version <= 3.3, which is not my case I think (how do i check?)
here is my wsgi that starts the app
#!/usr/bin/env python3
import os
import sys
import logging
logging.basicConfig(stream=sys.stderr)
PROJECT_DIR = '/var/www/Monitor/'
sys.path.insert(0, PROJECT_DIR)
def execfile(filename):
globals = dict(__file__ = filename)
exec(open(filename).read(), globals)
activate_this = '/var/www/Monitor/Monitor/venv/bin/activate_this.py'
execfile(activate_this)
from Monitor import app as application
Any help would be very much appreciated. Any additional information will be supplied if necessary.
Default Python3 on Debian 7 is 3.2.3, libapache2-mod-wsgi is in version 3.3.
You Apache run Your app with default Python because mod-wsgi has to be compiled against one and only one python version (in this case python 3.3).
mod-wsgi 3.3
If You want to run only one app (or many apps) with Python 3.4, try to recompile mod-wsgi with python 3.4
mod-wsgi 4.1.x or newer
This newer version of mod_wsgi provides a way of installing mod_wsgi against multiple Python versions and running up an Apache instance for each using a provided script. The script takes over all the setup of the Apache configuration so you do not need to worry about it.
https://pypi.python.org/pypi/mod_wsgi
old answer
To change Python version, set in Apache conf:
WSGIPythonHome /usr/local/opt/python3.4.3/
WSGIPythonPath /var/www/Monitor:/var/www/Monitor/Monitor/venv/lib/python3.4/site-packages:/usr/local/opt/python3.4.3/lib/site-packages
for details read https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonHome
I have successfully installed trac 1.0 . It is running fine when in standalone mode .
I am getting the following error after doing the integration with Apache mod_wsgi
mod_wsgi (pid=23895): Exception occurred processing WSGI script '/var/www/cgi-bin/trac_pcbb.trac.wsgi'.
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] Traceback (most recent call last):
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] File "/var/www/cgi-bin/trac_pcbb.trac.wsgi", line 30, in application
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] from trac.web.main import dispatch_request
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] ImportError: No module named trac.web.main
I am trying to install mod_wsgi on apache2, on ubuntu.
So I install libapache2-mod-wsgi package, I activate him with a2enmod.
I got a web site (languageAnalyz), that I am trying to use with mod_wsgi.
When I call localhost/languageAnalyz, I got an error 500.
In apache2 log, I can see this :
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] mod_wsgi (pid=4993): Target WSGI script '/var/www/languageAnalyz/test-wsgi.py' cannot be loaded as Python module.
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] mod_wsgi (pid=4993): SystemExit exception raised by WSGI script '/var/www/languageAnalyz/test-wsgi.py' ignored.
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] File "/var/www/languageAnalyz/test-wsgi.py", line 10, in <module>
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] WSGIServer(app).run()
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi.py", line 112, in run
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] sock = self._setupSocket()
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 997, in _setupSocket
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] req.run()
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 572, in run
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] self._end(appStatus, protocolStatus)
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 601, in _end
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] sys.exit(appStatus)
[Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] SystemExit: 0
I googled this error, and I find lot of solutions (most of the times for Django project).
What I undsertand, is that I need to create a __init__.py file.
What I did, here is my __init__.py file :
__all__ = ['app','get_size_dir','get_nbrf_dir','getStats'] #name of my functions
import index # my three python files
import analyz
import test-wsgi
In the __all__ list, this is the name of the functions in the three files.
I am just trying to launch test-wsgi.py, and get the same error 500.
Here is my test-wsgi.py file :
import os,sys
sys.path.append(os.path.dirname(__file__))
from cgi import escape,parse_qs
from flup.server.fcgi import WSGIServer
def app(environ, start_response):
start_response('200 OK',[('Content-Type','text/plain; charset=utf-8')])
yield "hello world!"
WSGIServer(app).run()
So what's wrong ?
Thank you,
Edit :
here is my apache2 conf :
WSGIPythonPath /var/www/languageAnalyz
<VirtualHost *:80>
...
<Directory /var/www/languageAnalyz/>
Options +Indexes ExecCGI FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.py
SetHandler wsgi-script
</Directory>
...
</VirtualHost>
Edit_bis :
So I try to do as I read on django doc.
I change my apache2 conf to :
WSGIPythonPath /var/www/languageAnalyz
<VirtualHost *:80>
...
WSGIScriptAlias /IPA /var/www/languageAnalyz/testwsgi.py
<Directory /var/www/languageAnalyz/>
Options +Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex testwsgi.py
</Directory>
...
</VirtualHost>
I restart apache2, and I got the same error, and one more before :
[Sun Aug 25 12:47:18 2013] [notice] caught SIGTERM, shutting down
[Sun Aug 25 12:47:19 2013] [notice] FastCGI: wrapper mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Sun Aug 25 12:47:19 2013] [notice] FastCGI: process manager initialized (pid 7879)
[Sun Aug 25 12:47:19 2013] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Sun Aug 25 12:47:19 2013] [notice] mod_python: using mutex_directory /tmp
[Sun Aug 25 12:47:19 2013] [warn] mod_wsgi: Compiled for Python/2.7.3.
[Sun Aug 25 12:47:19 2013] [warn] mod_wsgi: Runtime using Python/2.7.4.
[Sun Aug 25 12:47:19 2013] [notice] Apache/2.2.22 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 PHP/5.4.9-4ubuntu2.2 mod_python/3.3.1 Python/2.7.4 mod_ruby/1.2.6 Ruby/1.8.7(2012-02-08) mod_wsgi/3.4 configured$
[Sun Aug 25 12:47:19 2013] [error] WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
[Sun Aug 25 12:47:19 2013] [error] WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
[Sun Aug 25 12:47:19 2013] [error] WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
[Sun Aug 25 12:47:19 2013] [error] WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
[Sun Aug 25 12:47:19 2013] [error] Status: 200 OK\r
[Sun Aug 25 12:47:19 2013] [error] Content-Type: text/plain; charset=utf-8\r
[Sun Aug 25 12:47:19 2013] [error] \r
[Sun Aug 25 12:47:19 2013] [error] hello world!
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7884): Target WSGI script '/var/www/languageAnalyz/testwsgi.py' cannot be loaded as Python module.
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7884): SystemExit exception raised by WSGI script '/var/www/languageAnalyz/testwsgi.py' ignored.
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] File "/var/www/languageAnalyz/testwsgi.py", line 10, in <module>
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] WSGIServer(app).run()
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi.py", line 112, in run
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] sock = self._setupSocket()
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 997, in _setupSocket
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] req.run()
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 572, in run
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] self._end(appStatus, protocolStatus)
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 601, in _end
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] sys.exit(appStatus)
[Sun Aug 25 12:47:19 2013] [error] [client 127.0.0.1] SystemExit: 0
Edit_ter :
Ok, I just successfully launch testwsgi.py. I change my app function into application, and I add some lines at the end :
if __name__ == '__main__':
from wsgiref.simple_server import make_server
server = make_server('localhost', 8080, application)
server.serve_forever()
I event don't know, why it's working, why it was not working before. ... And now I got some problem to open files, with their path (config files, or templates files ...)
[Sun Aug 25 13:10:51 2013] [error] [client 127.0.0.1] File "/var/www/languageAnalyz/analyz.py", line 22, in getStats
[Sun Aug 25 13:10:51 2013] [error] [client 127.0.0.1] flangs=open('config/languages.yml')
I try with absolute path, it didn't work too ...
You would appear to be following the wrong documentation for starters. For mod_wsgi use:
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/
You appear to be using documentation for FASTCGI deployment.
Also, you cannot do:
import test-wsgi
A Python module name cannot have '-' in it.
In summary, go reread (or read) the Django documentation on deployment.
For me the problem was wsgi python version mismatch. I was using python 3, so:
$ sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi
$ sudo apt-get install libapache2-mod-wsgi-py3
I had the same problem for a differnt file and making the file world executable fixed it for me. You would of course want to lock it down to the required user after you have narrowed this down as your issue:
chmod a+x test-wsgi.py
Installed Python and Django on a Windows Server 2008 R2 Wamp Machine. Everything's fine, except a ported version of a django/python website which were on a LAMP machine previously.
500 internal server error when accessing the vhost via web browser
I get this error log from apache:
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] mod_wsgi (pid=1788): Exception occurred processing WSGI script 'C:/Wamp/www/mysite_com/mysite_com.wsgi'.
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 255, in __call__
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] response = self.get_response(request)
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 178, in get_response
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 220, in handle_uncaught_exception
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] if resolver.urlconf_module is None:
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\django\\core\\urlresolvers.py", line 342, in urlconf_module
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] self._urlconf_module = import_module(self.urlconf_name)
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\django\\utils\\importlib.py", line 35, in import_module
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] __import__(name)
[Tue Aug 06 12:29:27 2013] [error] [client 127.0.0.1] ImportError: No module named urls
This is my .wsgi app:
import os, sys
sys.path.append('c:/Wamp/www/')
os.environ ['DJANGO_SETTINGS_MODULE'] = 'mysite_com.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
And my apache vhosts
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot "C:/Wamp/www/mysite_com/"
WSGIScriptAlias / "C:/Wamp/www/mysite_com/mysite_com.wsgi"
</VirtualHost>
folder structure
\www
\mysite_com
\__init__.py
\settings.py
\urls.py
\manage.py
\mysite_com.wsgi
Any advice?
Thanks
You're adding the site path to your system path wrong. See in Linux you would use forward slashes '/' while in windows (which you seem to be using) backward slashes '\'. Of course, you need to double them up so it won't be rendered as escape strings:
sys.path.append('C:\\wamp\\www')
of course, it would be much easier like this:
sys.path.append(r'C:\wamp\www')
And see - your server can find the wsgi application because you told apache where to find it, so it complains about the next module that it can't find (which just happens to be urls.py). I already answered in a comment but I thought an explanation of why you saw the error that specific way would help.
p.s.
If that still doesn't work you might need to append the path to your actual application:
sys.path.append(r'C:\Wamp\www\mysite_com')
Totally new to python-based web apps, so I'm somewhat lost. Here is my apache error:
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] mod_wsgi (pid=23704): Target WSGI script '/home/http/public/hello/hello.wsgi' cannot be loaded as Python module.
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] mod_wsgi (pid=23704): Exception occurred processing WSGI script '/home/http/public/hello/hello.wsgi'.
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] Traceback (most recent call last):
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] File "/home/http/public/hello/hello.wsgi", line 3, in <module>
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] from hello import app as application
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] File "/home/http/public/hello/hello.py", line 1, in <module>
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] from flask import Flask
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] ImportError: No module named 'flask'
[Wed May 08 22:41:47 2013] [error] [client 64.56.91.45] File does not exist: /home/http/public/favicon.ico
Apparently, it cannot find the flask module. I've looked this up, and it seems that most people get it to work by appending the project directory to the path, like so: (hello.wsgi)
import sys
sys.path.insert(0, "/home/http/public/hello")
from hello import app as application
And here is hello.py:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0')
Works great when ran as python hello.py, however, throws a 500 error when browsing to host/hello. Here's the Apache configuration:
WSGIDaemonProcess hello user=http group=http threads=5
WSGIScriptAlias /hello "/home/http/public/hello/hello.wsgi"
<Directory /home/http/public/hello/>
WSGIProcessGroup hello
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
I'm somewhat lost.
The mod_wsgi module is built against a specific Python version and can only work with that version. You cannot force it to use a different version. Thus if you have multiple versions installed, you need to make sure that you are installing your packages and running your code in development against the same version.
You can determine which Python version/installation mod_wsgi is using by running the test:
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use