Once I get 2.4 and 3.0 out of the way I will be revisiting the documentation and trying to work out what to do about it all. I agree that it needs to be more step wise and offers lots more warnings, but to do it properly you almost need a mini book on deploying it for each different major framework. The wiki isn't really suited for that.
2009/4/1 Tim Valenta <tonightslasts...@gmail.com>: > Ah, see-- even though I've read the Django docs and knew that a Django > project didn't (and shouldn't) be in a public document root, I had only been > thinking this was advice for a development server. I had logged away this > information and forgotten to apply it to the more important production side > of the equation. > So I guess then my confusion is that I would not have named the parent > directory of my django project "django", since that's what I would have > called the SVN checkout, or what have you. I would still adapt the examples > to maybe dish out the quick reminder that your django project doesn't have > to be in any particular place. Then I would suggest the examples make use > of a different path, such as /usr/local/myprojects/mysite (or something), > rather than /usr/local/django. > All this time I was thinking that /usr/local/django was the spot where the > django framework was residing, so as to account for the framework not > already being on your production machine's global pythonpath variable. > Hence all the confusion :) Terribly sorry for the circles I've driven in. > Very glad to have finally sorted this out. > > On Tue, Mar 31, 2009 at 11:33 PM, Graham Dumpleton > <graham.dumple...@gmail.com> wrote: >> >> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>: >> > Hm... yes, I had read that before, but I hadn't immediately caught the >> > reference to the fact that "/usr/local/django" was itself the document >> > root. >> > I (personally) would suggest making a slight alteration to that >> > documentation, simply to state more explicitly that it is the apache >> > documentroot itself being added to the sys.path. >> >> You probably mean Apache server root, not document root. Putting stuff >> under the Apache document root is dangerous as document root is >> exposed as static files normally and so by putting stuff under there >> you expose your source code and settings file with the passwords in >> it. >> >> Either way, Django stuff could be put anywhere. Thus the directory >> '/usr/local/django' is just representative of where ever you put it. I >> don't want to be having an example that goes anywhere near the Apache >> server root or document root because as soon as you do that, people >> are more likely to actually start putting it in the document root and >> causes themselves no end of problems. >> >> Graham >> >> > Thanks >> > Tim >> > >> > On Tue, Mar 31, 2009 at 11:16 PM, Graham Dumpleton >> > <graham.dumple...@gmail.com> wrote: >> >> >> >> 2009/4/1 Tim Valenta <tonightslasts...@gmail.com>: >> >> > One final hurrah for the import error. So I've gotten everything >> >> > running >> >> > this evening (thanks to direction given previously). The last thing >> >> > I'm >> >> > noting is this: >> >> > My setup isn't particularly strange, in my opinion, yet I needed to >> >> > add >> >> > one >> >> > more place to the sys.path to get things rolling. >> >> > Consider this: apache's document root is set to /var/www/. I make a >> >> > Django >> >> > site (or any for that matter, but bear with me) and copy the whole >> >> > project >> >> > directory into /var/www. This leaves me with my site actually >> >> > residing >> >> > in >> >> > /var/www/mysite/. >> >> > I use the ./mysite/apache/ directory for the django.wsgi file. >> >> > django.wsgi >> >> > simply appends Django and /var/www/mysite onto the sys.path. The >> >> > following >> >> > line is also present (as usual): >> >> > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' >> >> > >> >> > Yet once the wsgi handler has been launched from this >> >> > ./apache/django.wsgi >> >> > file, I repeated had errors in the apache log about not being able to >> >> > import >> >> > the mysite.settings module. It wasn't a huge jump of logic to see >> >> > what >> >> > was >> >> > happening... /var/www/mysite is on the sys.path, but when I say >> >> > mysite.settings, it was looking for a mysite module within the >> >> > /var/www/mysite, which it can't find. On the other hand, if I >> >> > changed >> >> > the >> >> > os.environ setting in django.wsgi to just "settings" (and not >> >> > "mysite.settings"), then it worked great. >> >> > That doesn't seem natural though, especially if you're trying to have >> >> > more >> >> > than one django site in apache. So I changed things to this, which >> >> > yield >> >> > the more expected results: django.wsgi doesn't put /var/www/mysite >> >> > on >> >> > sys.path, but instead /var/www. Then I place an "__init__.py" file >> >> > in >> >> > my >> >> > /var/www, so that mysite.settings can be resolved to my site's >> >> > settings >> >> > module. >> >> > I have no idea if this seems strange to anybody, but again-- I don't >> >> > think >> >> > I'm straying very far from a normal setup, yet the base instructions >> >> > found >> >> > on either django or mod_wsgi's documentation seems to reference the >> >> > scenario >> >> > as I've explained it. >> >> > Am I missing something rather foundational, or do my actions seem >> >> > fairly >> >> > expected, given the situation? Even if prior documentation assumes >> >> > that >> >> > "mysite" *is* the apache document root (by global setting or >> >> > virtualhost), I >> >> > don't think it would have worked. >> >> > Can someone clarify, if needed? >> >> > Thanks for help up to this point. I'm at least glad that it's >> >> > running >> >> > :P >> >> >> >> Which equates to what the mod_wsgi wiki documentation says: >> >> >> >> """The directory added to sys.path would be the directory containing >> >> the package for the Django site created by running: >> >> >> >> django-admin.py startproject mysite >> >> >> >> If you have been using the Django development server and have made use >> >> of the fact that it is possible when doing explicit imports, or when >> >> referencing modules in 'urls.py', to leave out the name of the site >> >> and use a relative module path, you will also need to add to sys.path >> >> the path to the site package itself. >> >> >> >> sys.path.append('/usr/local/django') >> >> sys.path.append('/usr/local/django/mysite') >> >> """ >> >> >> >> So, both the directory containing the settings file as well as its >> >> parent. >> >> >> >> Graham >> >> >> >> >> >> > Tim >> >> > On Tue, Mar 31, 2009 at 7:42 PM, Tim Valenta >> >> > <tonightslasts...@gmail.com> >> >> > wrote: >> >> >> >> >> >> Okay-- confusion has been ironed out. I originally had no doubt >> >> >> that >> >> >> there should have been an apache <Directory> directive for the file, >> >> >> but I >> >> >> must have misinterpreted your comments earlier. >> >> >> Thanks again for the details. >> >> >> >> >> >> On Tue, Mar 31, 2009 at 7:39 PM, Graham Dumpleton >> >> >> <graham.dumple...@gmail.com> wrote: >> >> >>> >> >> >>> 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." >> >> >>> > >> >> >>> > > >> >> >>> > >> >> >>> >> >> >>> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> "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 -~----------~----~----~----~------~----~------~--~---