Reputation: 12068
In order to debugg a bottle.py application I'm trying to deploy to openshift (with a problem I suspect is connected to mod_wsgi - this open question) I'm trying to run mod_wsgi on my linux station. as the title states - I'm failing miserably.
I downloaded and installed mod_wsgi compiled to python2.6 according to the instructions in the mod_wsgi wiki.
running apache2ctl -M I verified that mod_wsgi(shared) is in the resulting list so I guess I've got that part right
I wrote an appname file in the /etc/apache2/sites-availble containing:
<VirtualHost *:8051> #also tried with * or *:80 or myappname
# ServerName 127.0.0.1:8051 #also tried to uncomment
ServerAlias wikimen #also tried without
# WSGIDaemonProcess wikimen user=myusername group=myusername threads=5 #also tried to uncomment
WSGIScriptAlias / /home/myusername/workspace/myapp/wsgi/application
DocumentRoot /home/myusername/workspace/myapp/wsgi
<Directory /home/myusername/workspace/myapp/wsgi>
# WSGIProcessGroup myapp
# WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
and after running:
sudo a2ensite
checked that it was created accordingly in sites-enabled dir and run:
sudo service apacha2 reload
when I go to the browser and try: localhost:8051 or localhost/appname/routename or localhost:8051/routename or localhost:8051/appname or any other combination between them I just get (also when changing localhost to 127.0.0.1) :
unable to connect
the wsgi handle file (named "application") contains:
#!/usr/bin/python
import os
here = os.path.dirname(os.path.abspath(__file__))
try:
os.environ['PYTHON_EGG_CACHE'] = os.path.join(os.environ['OPENSHIFT_APP_DIR'],'virtenv/lib/python2.6/site-packages')
except:
os.environ['PYTHON_EGG_CACHE'] = os.path.join(here,'..','data/virtenv/lib/python2.6/site-packages')
print ('python egg cache set to: %s' % os.environ['PYTHON_EGG_CACHE'])
try:
virtualenv = os.path.join(os.environ['OPENSHIFT_APP_DIR'],"virtenv/bin/activate_this.py")
except:
virtualenv = os.path.join(here,'..',"data/virtenv/bin/activate_this.py")
print ('virtualenv is in:%s' % virtualenv)
try:
execfile(virtualenv, dict(__file__=virtualenv))
print ('executed')
except IOError:
pass
from myappname import application
but as I said It does work (also invokes some strange bottle.py mistake) in the openshift server so I guess this isn't the problem also I'll be glad to be refuted
maybe I should mention that the wsgi "application" file as the rest of the app are in a virtualenv directory
I'm not really good with apache (our production server is cherokee using reverse proxy and native python servers and not mod_wsgi) so maybe I'm missing something basic
the basic bottle.py runs if I run it directly withput the wsgi handle I'll be glad for any help
using: ubunto 11, apache2.2, the current mod_wsgi version, python 2.6 (I also have python 2.7 but the app runs in a virtualenv of python2.6 in according to the openshift server)
tailing the apache2 error log doesn't show anything usefull (also killing it and starting again):
> [Sat Mar 24 15:45:10 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sat Mar 24 21:19:24 2012]
> [notice] caught SIGTERM, shutting down [Sat Mar 24 21:19:54 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sat Mar 24 21:36:30 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sat Mar 24 21:40:48 2012]
> [notice] caught SIGTERM, shutting down [Sat Mar 24 21:41:18 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sat Mar 24 23:47:11 2012] [notice] Apache/2.2.20 (Ubuntu)
> PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.7
> configured -- resuming normal operations [Sun Mar 25 22:20:22 2012]
> [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with
> Suhosin-Patch mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal
> operations [Sun Mar 25 22:34:12 2012] [notice] caught SIGTERM,
> shutting down [Sun Mar 25 22:34:24 2012] [notice] Apache/2.2.20
> (Ubuntu) PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3
> Python/2.6.7 configured -- resuming normal operations
Upvotes: 1
Views: 613
Reputation: 58523
I you are getting 'unable to connect' in your browser then nothing to do with mod_wsgi and instead your browser can't even connect to the server. Amend your question with any error messages which you find in the Apache error log? It is possible that your Apache isn't even starting up due to bad configuration files.
Upvotes: 1