2009/4/1 Tim Valenta <tonightslasts...@gmail.com>:
> So then to clear up a little confusion from my end.. is there any need to be
> putting that ./apache/ directory in the apache conf at all,

Yes, there must be a Directory container as previously showed for the
'apache' directory. This is required to satisfy the Apache security
model. That is, Apache will not serve up static files or allow
execution of script files from directories that it hasn't been told it
is allowed to expose to web clients. Apache documentation about this
at:

  http://httpd.apache.org/docs/2.2/howto/access.html

> given the
> simplicity of the examples being shown on either site (mod_wsgi or django)?
>  This is primarily the kind of little confusing points that led me to seek
> other documentation (it was a 2-way road from wsgi to django, django to
> wsgi) for clarification.  Someone like myself might benefit from an end-all
> example template of the base necessities needed to get it off the ground.
>  (Which I still haven't done, despite more efforts on my end.)

The mod_wsgi wiki documentation is the minimal example. It is the one
on the Django site which has confused everything by moving stuff into
different locations.

Graham

> On Tue, Mar 31, 2009 at 7:18 PM, Graham Dumpleton
> <graham.dumple...@gmail.com> wrote:
>>
>> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>:
>> > Unless I've made a mistake in my thinking, I believe that the
>> > IntegrationWithDjango page also states that you should put that
>> > ./apache/
>> > directory in your apache conf
>> > (http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango)
>> >
>> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
>> >
>> >
>> >
>> > <Directory /usr/local/django/mysite/apache>
>> >
>> >
>> > Order deny,allow
>> >
>> >
>> > Allow from all
>> >
>> >
>> > </Directory>
>> >
>> > Now I'm not sure what to think, since I now see this on both sets of
>> > documentation :)
>>
>> Yes, but the mod_wsgi wiki documents don't say to put the settings
>> files in that directory. It is the location of the settings files
>> which is the problem from the security perspective.
>>
>> The warning I have put on the page on Django site for now is:
>>
>> """NOTE: Putting settings file in the 'apache' subdirectory where the
>> WSGI script file is located is technically a security risk. This is
>> because in order for the WSGI script file to be served from there, you
>> have had to configure Apache to tell it it can use that directory. In
>> doing that, it can technically serve files from there as static files.
>> Thus, if Apache was incorrectly configured and files in that directory
>> made accessible via a URL as static files, it would be possible to
>> download the settings file. Since the settings file can contain
>> database passwords, that obviously isn't going to be a good thing to
>> happen. This example really should be modified, with settings files
>> located one directory up from where they are, as would normally be the
>> case."""
>>
>> Graham
>>
>> > Tim
>> > On Tue, Mar 31, 2009 at 5:56 PM, Tim Valenta
>> > <tonightslasts...@gmail.com>
>> > wrote:
>> >>
>> >> Oops, I believe we replied at the same time-- This document may be
>> >> dropped
>> >> in favor of the one you've linked to earlier today (which might be a
>> >> keen
>> >> suggestion to make to django peoplez).
>> >> On Tue, Mar 31, 2009 at 5:55 PM, Tim Valenta
>> >> <tonightslasts...@gmail.com>
>> >> wrote:
>> >>>
>> >>> Yes, the example was shown on the django wiki, found
>> >>> here: http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
>> >>> It beings in the section talking about an "apache_django_wsgi.conf"
>> >>> file,
>> >>> which is suggests you include at the bottom of your main httpd.conf.
>> >>>  It
>> >>> suggests adding a few directives and aliases to this included conf
>> >>> fragment,
>> >>> the end of which goes like this:
>> >>>
>> >>> WSGIScriptAlias / "<PATH TO YOUR DJANGO
>> >>> PROJECT>/apache/dj_survey.wsgi"
>> >>>
>> >>> <Directory "<PATH TO YOUR DJANGO PROJECT>/apache">
>> >>> Allow from all
>> >>> </Directory>
>> >>>
>> >>> ... where "dj_survey" is the example site name.
>> >>> For all I know, this page might sink into oblivion, in favor of the
>> >>> link
>> >>> you provided earlier, where Django's SVN docs suggest mod_wsgi over
>> >>> mod_python
>> >>> (http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/)
>> >>>
>> >>> On Tue, Mar 31, 2009 at 5:49 PM, Graham Dumpleton
>> >>> <graham.dumple...@gmail.com> wrote:
>> >>>>
>> >>>> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>:
>> >>>> > Yes, I did.  Now that you mention it, I am not sure why I felt I
>> >>>> > needed to
>> >>>> > do that.
>> >>>> > ... Something must have prompted me to do it, but I cannot remember
>> >>>> > now.  It
>> >>>> > must have had something to do with seeing the following example
>> >>>> > line:
>> >>>> >
>> >>>> > os.environ['DJANGO_SETTINGS_MODULE'] =
>> >>>> > 'mysite.apache.settings_production'
>> >>>> >
>> >>>> > ... And then misinterpreting/misreading the example lines on the
>> >>>> > mod_wsgi
>> >>>> > page for IntegrationWithDjango:
>> >>>> >
>> >>>> > sys.path.append('/usr/local/django')
>> >>>> >
>> >>>> >
>> >>>> > sys.path.append('/usr/local/django/mysite')
>> >>>> >
>> >>>> > So, looks like I was being more daft than I originally thought.
>> >>>> >  Note
>> >>>> > to
>> >>>> > self (and anybody else who ever finds themselves being equally
>> >>>> > daft):
>> >>>> > there
>> >>>> > is no reason to put the ./apache/ directory in the sys.path; only a
>> >>>> > need to
>> >>>> > make sure it can get there if needed, by providing the
>> >>>> > ./apache/__init__.py
>> >>>> > file (if wanting to import a production settings/urls file from
>> >>>> > ./apache/)
>> >>>>
>> >>>> Except that you wouldn't even want to be putting anything in the
>> >>>> 'apache' directory besides the WSGI script file.
>> >>>>
>> >>>> The reason for this is that one has to tell Apache that is is okay to
>> >>>> use stuff in the 'apache' directory. This is done with the Directory
>> >>>> directive container of the form:
>> >>>>
>> >>>> <Directory /some/path/mysite/apache>
>> >>>> Order deny,allow
>> >>>> Allow from all
>> >>>> </Directory>
>> >>>>
>> >>>> By doing that, you are technically also saying that it could serve up
>> >>>> static files in that directory. Of course  that would only eventuate
>> >>>> if Apache configuration was screwed up such that you exposed that
>> >>>> directory via a URL somehow.
>> >>>>
>> >>>> If this was accidentally done and you had settings files in there,
>> >>>> someone could potentially access your settings file and any database
>> >>>> passwords in it.
>> >>>>
>> >>>> You might therefore see why always have the WSGI script file in
>> >>>> directory by itself. It just reduces risk of exposing stuff you
>> >>>> shouldn't if Apache misconfigured.
>> >>>>
>> >>>> For similar reasons, should never stick a Django project under Apache
>> >>>> document root. Don't set up Apache properly and people could download
>> >>>> your source code.
>> >>>>
>> >>>> if you remember where you saw example of putting settings stuff in
>> >>>> 'apache' directory let me know. If it was a blog entry I'll try and
>> >>>> add a comment against it indicating how bad it is. :-)
>> >>>>
>> >>>> Graham
>> >>>>
>> >>>> > Thanks for continuing to work through it-- I was clearly burned out
>> >>>> > yesterday, and my troubles were self-created!
>> >>>> > Tim
>> >>>> > On Tue, Mar 31, 2009 at 5:28 PM, Graham Dumpleton
>> >>>> > <graham.dumple...@gmail.com> wrote:
>> >>>> >>
>> >>>> >> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>:
>> >>>> >> > Yes, the file path was mysite/apache/django.wsgi .  I was
>> >>>> >> > getting
>> >>>> >> > unhelpful
>> >>>> >> > server-500 errors when loading apache (which I haven't fully
>> >>>> >> > resolved
>> >>>> >> > yet--
>> >>>> >> > will try tonight), so I was trying to run the .wsgi file all by
>> >>>> >> > itself,
>> >>>> >> > to
>> >>>> >> > confirm that nothing was amiss in the Python code itself.
>> >>>> >> > Thus I had renamed it to mysite/apache/django.py and was just
>> >>>> >> > executing
>> >>>> >> > it
>> >>>> >> > for testing.  Within that code, I was saying "django.core.....",
>> >>>> >> > which
>> >>>> >> > would
>> >>>> >> > circling back on itself, since the first directory checked would
>> >>>> >> > have
>> >>>> >> > been
>> >>>> >> > its own executing directory.
>> >>>> >> > I have a settings_production.py file in the same ./apache/
>> >>>> >> > directory,
>> >>>> >> > but as
>> >>>> >> > of yet, it's not in use.
>> >>>> >>
>> >>>> >> The only thing in the 'apache' subdirectory should be the WSGI
>> >>>> >> script
>> >>>> >> file, and you should not be adding that directory to sys.path. I
>> >>>> >> can't
>> >>>> >> see at the moment how calling it django.py could have caused a
>> >>>> >> problem
>> >>>> >> as long as you hadn't added that directory to sys.path.
>> >>>> >>
>> >>>> >> So, had you added the 'apache' directory to sys.path?
>> >>>> >>
>> >>>> >> Graham
>> >>>> >>
>> >>>> >> > On Tue, Mar 31, 2009 at 4:56 PM, Graham Dumpleton
>> >>>> >> > <graham.dumple...@gmail.com> wrote:
>> >>>> >> >>
>> >>>> >> >> Where have you put the WSGI script file? If it was put in an
>> >>>> >> >> 'apache'
>> >>>> >> >> subdirectory, as the documentation indicates, instead of same
>> >>>> >> >> directory as the settings.py file you shouldn't have this
>> >>>> >> >> problem.
>> >>>> >> >>
>> >>>> >> >> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>:
>> >>>> >> >> > Hello Graham-- Late last night before falling asleep I
>> >>>> >> >> > realized
>> >>>> >> >> > that
>> >>>> >> >> > this
>> >>>> >> >> > could be the only explanation, and suddenly realized that--
>> >>>> >> >> > in
>> >>>> >> >> > fact--
>> >>>> >> >> > the
>> >>>> >> >> > very .wsgi file I wanted to test was called "django.wsgi",
>> >>>> >> >> > which
>> >>>> >> >> > I
>> >>>> >> >> > had
>> >>>> >> >> > renamed to "django.py" for something of a unit-test.
>> >>>> >> >> >  Therefore,
>> >>>> >> >> > my
>> >>>> >> >> > import
>> >>>> >> >> > was finding itself first, no matter where I was running the
>> >>>> >> >> > lone
>> >>>> >> >> > file.
>> >>>> >> >> > Ultimately the issue was me being daft :)  About 10 minutes
>> >>>> >> >> > ago
>> >>>> >> >> > before
>> >>>> >> >> > leaving the house this morning, I turned on the monitor and
>> >>>> >> >> > renamed
>> >>>> >> >> > the
>> >>>> >> >> > file
>> >>>> >> >> > and tested again, and it worked without any of the above
>> >>>> >> >> > mentioned
>> >>>> >> >> > issues.
>> >>>> >> >> > Thanks for the reply.
>> >>>> >> >> > Tim
>> >>>> >> >> >
>> >>>> >> >> > On Mon, Mar 30, 2009 at 11:44 PM, Graham Dumpleton
>> >>>> >> >> > <graham.dumple...@gmail.com> wrote:
>> >>>> >> >> >>
>> >>>> >> >> >> 2009/3/31 Tim Valenta <tonightslasts...@gmail.com>:
>> >>>> >> >> >> > Hello all--
>> >>>> >> >> >> >
>> >>>> >> >> >> > I've been casually trying to get mod_wsgi working in a
>> >>>> >> >> >> > Ubuntu
>> >>>> >> >> >> > 8.10
>> >>>> >> >> >> > sever, to
>> >>>> >> >> >> > run even the simplest of Django test projects.  So far,
>> >>>> >> >> >> > I've
>> >>>> >> >> >> > had
>> >>>> >> >> >> > no
>> >>>> >> >> >> > dice
>> >>>> >> >> >> > getting the example Django wsgi scripts to work.
>> >>>> >> >> >> >
>> >>>> >> >> >> > Most simply, I'm having an import error, which is baffling
>> >>>> >> >> >> > me
>> >>>> >> >> >> > beyond
>> >>>> >> >> >> > my
>> >>>> >> >> >> > sanity.  I've examined both the docs found on the mod_wsgi
>> >>>> >> >> >> > site,
>> >>>> >> >> >> > and
>> >>>> >> >> >> > also on
>> >>>> >> >> >> > Django's wiki system (found here:
>> >>>> >> >> >> >
>> >>>> >> >> >> > http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
>> >>>> >> >> >> > ).
>> >>>> >> >> >> >
>> >>>> >> >> >> > Currently, I've been following the latter docs, as they
>> >>>> >> >> >> > seemed
>> >>>> >> >> >> > more
>> >>>> >> >> >> > comprehensive from start to finish.
>> >>>> >> >> >> >
>> >>>> >> >> >> > No matter what I append to the sys.path variable in the
>> >>>> >> >> >> > example
>> >>>> >> >> >> > '.wsgi'
>> >>>> >> >> >> > file, I cannot import django.core.handlers.wsgi.  I get a
>> >>>> >> >> >> > "No
>> >>>> >> >> >> > module
>> >>>> >> >> >> > named
>> >>>> >> >> >> > core.handlers.wsgi" ImportError.  Running python from
>> >>>> >> >> >> > within
>> >>>> >> >> >> > the
>> >>>> >> >> >> > root
>> >>>> >> >> >> > SVN
>> >>>> >> >> >> > checkout of django, this import works wonderfully.
>> >>>> >> >> >> >  Elsewhere, not
>> >>>> >> >> >> > so.
>> >>>> >> >> >> >
>> >>>> >> >> >> > This might be more of a Python question than a mod_wsgi or
>> >>>> >> >> >> > django
>> >>>> >> >> >> > question,
>> >>>> >> >> >> > but am I wrong to assume that doing
>> >>>> >> >> >> > sys.path.append("/home/rydia/django")
>> >>>> >> >> >> > (where my svn checkout lives) should put that on my
>> >>>> >> >> >> > PythonPath,
>> >>>> >> >> >> > for
>> >>>> >> >> >> > proper
>> >>>> >> >> >> > module imports?
>> >>>> >> >> >> >
>> >>>> >> >> >> > Perhaps I'm just missing something very basic, but my head
>> >>>> >> >> >> > has had
>> >>>> >> >> >> > it
>> >>>> >> >> >> > today
>> >>>> >> >> >> > with more projects than I can handle :P
>> >>>> >> >> >> > Quick notes: apache itself runs great, aliases to my media
>> >>>> >> >> >> > directory
>> >>>> >> >> >> > works
>> >>>> >> >> >> > great, though I can't verify any success in the whole
>> >>>> >> >> >> > mod_wsgi
>> >>>> >> >> >> > department.
>> >>>> >> >> >>
>> >>>> >> >> >> Note the following:
>> >>>> >> >> >>
>> >>>> >> >> >> $ python
>> >>>> >> >> >> Python 2.3.5 (#1, Jan 12 2009, 14:43:55)
>> >>>> >> >> >> [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)] on
>> >>>> >> >> >> darwin
>> >>>> >> >> >> Type "help", "copyright", "credits" or "license" for more
>> >>>> >> >> >> information.
>> >>>> >> >> >> >>> import a.b
>> >>>> >> >> >> Traceback (most recent call last):
>> >>>> >> >> >>  File "<stdin>", line 1, in ?
>> >>>> >> >> >> ImportError: No module named a.b
>> >>>> >> >> >> >>> import os
>> >>>> >> >> >> >>> import os.c.d
>> >>>> >> >> >> Traceback (most recent call last):
>> >>>> >> >> >>  File "<stdin>", line 1, in ?
>> >>>> >> >> >> ImportError: No module named c.d
>> >>>> >> >> >>
>> >>>> >> >> >> If you import a module where top level module doesn't exist,
>> >>>> >> >> >> the
>> >>>> >> >> >> ImportError, shows the full dotted path.
>> >>>> >> >> >>
>> >>>> >> >> >> If however you import a module where the top level module
>> >>>> >> >> >> does
>> >>>> >> >> >> exist,
>> >>>> >> >> >> but the sub modules don't, then only the missing sub modules
>> >>>> >> >> >> are
>> >>>> >> >> >> listed in the ImportError.
>> >>>> >> >> >>
>> >>>> >> >> >> In your case the error says "No module named
>> >>>> >> >> >> core.handlers.wsgi".
>> >>>> >> >> >> This
>> >>>> >> >> >> means that the 'django' top level module was found, but that
>> >>>> >> >> >> there
>> >>>> >> >> >> were no sub modules of the names requested in it.
>> >>>> >> >> >>
>> >>>> >> >> >> What is likely therefore happening is one of a few things.
>> >>>> >> >> >>
>> >>>> >> >> >> 1. You are running Apache such that code runs as Apache user
>> >>>> >> >> >> and
>> >>>> >> >> >> although that user has access to top level 'django' package
>> >>>> >> >> >> directory,
>> >>>> >> >> >> it doesn't have permissions to read sub modules.
>> >>>> >> >> >>
>> >>>> >> >> >> 2. You have a file based module called 'django.py' somewhere
>> >>>> >> >> >> on
>> >>>> >> >> >> your
>> >>>> >> >> >> path and it is finding that first. That or it is a directory
>> >>>> >> >> >> called
>> >>>> >> >> >> 'django' and it has in it a '__init__.py' file.
>> >>>> >> >> >>
>> >>>> >> >> >> What I suggest you do is add the following to the start of
>> >>>> >> >> >> your
>> >>>> >> >> >> .wsgi
>> >>>> >> >> >> script file.
>> >>>> >> >> >>
>> >>>> >> >> >>  import sys
>> >>>> >> >> >>  import django
>> >>>> >> >> >>
>> >>>> >> >> >>  print >> sys.stderr, 'django __file__', django.__file__
>> >>>> >> >> >>
>> >>>> >> >> >> Look at the Apache error log to see where that 'django' top
>> >>>> >> >> >> level
>> >>>> >> >> >> module is being picked up from. See if that is the one you
>> >>>> >> >> >> expect.
>> >>>> >> >> >> See
>> >>>> >> >> >> if everything looks to have correct permissions. See if it
>> >>>> >> >> >> might
>> >>>> >> >> >> actually be some file module called 'django.py' or empty
>> >>>> >> >> >> 'django'
>> >>>> >> >> >> package directory.
>> >>>> >> >> >>
>> >>>> >> >> >> Post results as would be curious to know so can add this to
>> >>>> >> >> >> the
>> >>>> >> >> >> mind
>> >>>> >> >> >> back of problems that come up.
>> >>>> >> >> >>
>> >>>> >> >> >> Graham
>> >>>> >> >> >>
>> >>>> >> >> >>
>> >>>> >> >> >
>> >>>> >> >> >
>> >>>> >> >> >
>> >>>> >> >> > --
>> >>>> >> >> > "Python is the unholy bastard step-child between Ruby and
>> >>>> >> >> > PHP."
>> >>>> >> >> > "I'd let an ipod blow up on my leg for $150,000."
>> >>>> >> >> > "but Ben and Jerry do make a lovely couple."
>> >>>> >> >> >
>> >>>> >> >> > >
>> >>>> >> >> >
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >
>> >>>> >> >
>> >>>> >> >
>> >>>> >> > --
>> >>>> >> > "Python is the unholy bastard step-child between Ruby and PHP."
>> >>>> >> > "I'd let an ipod blow up on my leg for $150,000."
>> >>>> >> > "but Ben and Jerry do make a lovely couple."
>> >>>> >> >
>> >>>> >> > >
>> >>>> >> >
>> >>>> >>
>> >>>> >>
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > --
>> >>>> > "Python is the unholy bastard step-child between Ruby and PHP."
>> >>>> > "I'd let an ipod blow up on my leg for $150,000."
>> >>>> > "but Ben and Jerry do make a lovely couple."
>> >>>> >
>> >>>> > >
>> >>>> >
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> "Python is the unholy bastard step-child between Ruby and PHP."
>> >>> "I'd let an ipod blow up on my leg for $150,000."
>> >>> "but Ben and Jerry do make a lovely couple."
>> >>
>> >>
>> >>
>> >> --
>> >> "Python is the unholy bastard step-child between Ruby and PHP."
>> >> "I'd let an ipod blow up on my leg for $150,000."
>> >> "but Ben and Jerry do make a lovely couple."
>> >
>> >
>> >
>> > --
>> > "Python is the unholy bastard step-child between Ruby and PHP."
>> > "I'd let an ipod blow up on my leg for $150,000."
>> > "but Ben and Jerry do make a lovely couple."
>> >
>> > >
>> >
>>
>>
>
>
>
> --
> "Python is the unholy bastard step-child between Ruby and PHP."
> "I'd let an ipod blow up on my leg for $150,000."
> "but Ben and Jerry do make a lovely couple."
>
> >
>

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

Reply via email to