Deployment: Apache2, wsgi (Debian squeeze)
Hi, I made a multi choice quiz using django and was able to deploy it at: http://mattsmith.org.nz/django/test Thanks to the community for making these tools available. I am a self-taught programmer, this is the first time I have tried any web development so please be patient. I always find these groups intimidating but I really feel I have made a decent RTFM effort before making this post. Here are some things I know nothing about: Apache configuration. How http actually works. Up until now I've been serving non-dynamic content the usual way. I apt-got installed apache2, worked out /var/www was the root, followed the index.html convention and that worked fine. Now I feel I'm stuck between that old way of doing things and the django/wsgi way which I can't get my head around even after reading the docs. The development server experience hasn't helped me much when it comes to deployment. I wanted to connect the quiz to http://mattsmith.org.nz/test instead of http://mattsmith.org.nz/django/test but I couldn't see how to do that. I also want to convert the whole site to django so I can use child templates, but I cant work this out either. I guess my main question is this: Under the old scheme if someone types just my domain into their browser they get $DOCUMENT_ROOT/index.html, simple. What is the equivalent for the django/wsgi setup.? What do you put in urls.py? After reading the docs (they all say different things) I ended up with the following setup: /var/www/{oldStuff} /var/django/dogscience/apache/django.wsgi To help you help me you can see the following files from my system at http://mattsmith.org.nz/pleasehelp /etc/apache2/httpd.conf /var/django/dogscience/settings.py /var/django/dogscience/urls.py /var/django/dogscience/apache/django.wsgi Thank you, -- Matt Smith http://mattsmith.org.nz -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Deployment: Apache2, wsgi (Debian squeeze)
Thx Kenneth, Rohan, Melvyn. I've arrived at something that works: httpd.conf: WSGIScriptAlias / /usr/local/django/projectName/apache/django.wsgi Alias /static /usr/local/django/projectName/static So everything that's not a template lives under /usr/local/django/projectName/static. Is this ok? Does this mean when I link to say /static/foo.jpg in a template that foo.jpg is being served up by apache directly, ie not handled by wsgi? I've noticed that the site is slower to load up than before django? Is this normal? -- Matt Smith http://www.mattsmith.org.nz http://www.dogsciencenz.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Deployment: Apache2, wsgi (Debian squeeze)
On 10/07/12 08:08, Rohan wrote: Hi Matt, If you do not have static serving enabled in your django application mapping to /static/ in urls.py, then the content is being served by Apache. In settings.py I commented out the lines which assign MEDIA_ROOT, MEDIA_URL, and ADMIN_MEDIA_PREFIX because I couldn't see what they were good for, and I have no entry for /static/ in urls.py so I guess the content is being served by Apache, correct? What is your MaxRequestsPerChild in your apache conf? 0 for all of prefork, worker and event mpm's I apologise if this is OT for this list but I'm curious if you think the machine running apache is underpowered: mds@waianakarua:~$ grep MHz /proc/cpuinfo cpu MHz: 400.829 mds@waianakarua:~$ grep MemTotal /proc/meminfo MemTotal: 185644 kB Thx again, -- Matt Smith http://mattsmith.org.nz -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Can't use admin with apache
Background: I work on my projects using apache2 on my desktop machine, then just rsync across to the actual server (also apache2), that way I thought I could avoid the hassle of having things work with the dev server, but not with apache. Not so. Today I've discovered that the admin works under the dev server, but not with my apache setup. I replicated this using a brand new helloWorld project. I've searched the archives, the docs, the book, also ordinary web search. Found some people had similar problems and fixed it with apache Alias directives pointing ADMIN_MEDIA_PREFIX to DJANGO_SRC/contrib/admin/media but this didn't work for me. I get a 500 internal server error, regardless of DEBUG. Appreciate any help with this. -- Matt Smith http://mattsmith.org.nz -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can't use admin with apache
On 19/07/12 06:27, Demian Brecht wrote: What does your Apache log look like? What, exactly, is the 500? mod_wsgi (pid=18094): Exception occurred processing WSGI script '/usr/local/django/dogscience/apache/django.wsgi'. Traceback (most recent call last): ... File "/usr/lib/pymodules/python2.6/django/db/backends/sqlite3/base.py", line 200, in execute return Database.Cursor.execute(self, query, params) DatabaseError: attempt to write a readonly database mds@waitaki:/usr/local/django/dogscience$ ls -l sqlite3 -rw-r--r-- 1 mds staff 47104 Jul 18 17:41 sqlite3 Change: mds@waitaki:/usr/local/django/dogscience$ ls -l sqlite3 -rw-rw-rw- 1 www-data www-data 47104 Jul 18 17:41 sqlite3 - Now instead of DatabaseError: attempt to write a readonly database I get DatabaseError: unable to open database file Maybe I'll try a different db what do you think? A common issue when deploying is if your fcgi or wsgi script doesn't have the correct permissions set, which would cause an error that can't be caught by Django. mds@waitaki:/usr/local/django/dogscience$ ls -l apache/django.wsgi -rw-r--r-- 1 mds staff 1630 Jul 18 17:38 apache/django.wsgi How about this: Is anyone out there deploying on debian squeeze with the following packages: apache2 libapache2-mod-wsgi python-django If so, does the admin work for you? If it does, what db are you using? -- Matt Smith http://mattsmith.org.nz -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can't use admin with apache
On 19/07/12 11:06, Demian Brecht wrote: You're running ls -l under your user account. The apache process needs r+w permissions to the database file. Thx Demian my issue is now resolved (and I feel like a dumbass but who cares!) -- Matt Smith http://mattsmith.org.nz -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.