2008/12/2 Pietro Zambelli <[EMAIL PROTECTED]>:
>
> Hi,
> I have a problem to configure my server with apache mod_wsgi and
> django...
>
> On my server I have:
> linux kernel 2.6.27
> python 2.6-2
> apache 2.2.10 (Prefork)
> mod_wsgi 2.3-1
> django SVN-9538
>
> My djangosite is in /dati/www/geminiweb/ inside this folder I put my
> wsgi_handler.py

Don't put it in Django site folder, put it in a special subdirectory
of the Django site folder as illustrated in:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

The reason for this is that you need to expose that directory via
Apache with appropriate 'Allow' directive. If you do it for Django
site directory and then someone screws up Apache configuration, then
your source code is potentially downloadable.

> #=========================
> # /dati/www/geminiweb/wsgi_handler.py
> #=========================
> import sys
> import os
>
> sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'geminiweb.settings'

As also explained in documentation I reference above, if referencing
stuff without the site name from 'urls' mappings or via other loading
mechanisms, you need to add both the parent directory of the site,
plus the site directory itself.

> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
>
>
>
> I link the geminiweb folder in /srv/http/ where is set my DocumentRoot
> for apache server.
>
> Then I have added to the apache configuration file this text:
> #=========================
> # from httpd.conf
> #=========================
> <VirtualHost *>
>  ServerName gemini.ing.unitn.it:8080
>
> Alias /admin_media /usr/lib/python2.6/site-packages/django/contrib/admin/media
>
>  <Location /admin_media>
>    Order allow,deny
>    Allow from all
>  </Location>

This is bad practice. Generally one would not use Location directive
for this, use Directory directive and constrain to just the physical
directory that needs exposing.

  <Directory /usr/lib/python2.6/site-packages/django/contrib/admin/media>
  Order allow, deny
  </Directory.

The reason is that if done in Location directive, if Alias is
inadvertently pointed at somewhere it shouldn't it will automatically
expose it for access. With Directory, is harder to make mistakes.

>  Alias /media /srv/http/geminiweb/site-media
>
>  <Location /media>
>    Order allow,deny
>    Allow from all
>  </Location>

Same again:

  <Directory /srv/http/geminiweb/site-media>
  Order allow, deny
  Allow from all
  </Directory>

>  WSGIScriptAlias / /srv/http/geminiweb/wsgi_handler.py

As I said before, it really should be in subdirectory, but I find it
odd that you don't have:

  <Directory /srv/http/geminiweb>
  Order allow, deny
  Allow from all
  </Directory>

This should still be required even if using WSGIScriptAlias. If it is
working without it, suggests that elsewhere in Apache configuration
you are exposing the directory, either deliberately or accidentally.
You may want to investigate how this is the case.

>  WSGIDaemonProcess gemin user=pietro group=http processes=1 threads=10

Don't set 'processes=1', let it default to creating one process rather
than it being explicit. Using 'processes' option, even if value is
'1', results in wsgi.multiprocess being set as True. One would only
normally want this set for single process case when load balancing
across multiple web servers. By letting it default to creating one
process, wsgi.multiprocess will not be set.

Graham

>  WSGIProcessGroup gemin
>
> </VirtualHost>
>
>
>
> Now If I start the apache server and try to connect with a browser, I
> recive back this error:
> #=========================
> # browser error
> #=========================
> "Server error!
>
> The server encountered an internal error and was unable to complete your
> request. Either the server is overloaded or there was an error in a CGI
> script.
>
> If you think this is a server error, please contact the webmaster.
> Error 500"
>
>
>
> And if I look to the apache log error file
> #=========================
> # /var/log/httpd/error_log
> #=========================
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62] mod_wsgi
> (pid=15252): Exception occurred processing WSGI
> script '/srv/http/geminiweb/wsgi_handler.py'.
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62] Traceback (most
> recent call last):
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62]
> File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py",
> line 228, in __call__
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62]
> self.load_middleware()
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62]
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py",
> line 40, in load_middleware
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62]     raise
> exceptions.ImproperlyConfigured, 'Error importing
> middleware %s: "%s"' % (mw_module, e)
>
> [Mon Dec 01 15:05:24 2008] [error] [client 87.13.14.62]
> ImproperlyConfigured: Error importing middleware
> account.middleware: "No module named account.middleware"
>
>
> But if I try to load account.middleware module from the django shell I
> don't have any error...
> #=========================
> # django shell
> #=========================
> $ python manage.py shell
> Python 2.6 (r26:66714, Oct 27 2008, 10:50:31)
> [GCC 4.3.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>>>> from account import middleware
>>>>
>
>
> Somebody could tell me where is my error?
> Any Hints?
>
> Thanks for your help!
>
> Pietro
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to