Monday, January 27, 2014

Re: Problems Setting Up wsgi and Apache

Mark,

No offense taken.  I just really do find the topic of grammar
fascinating. 

I used to believe that the rules existed for a reason and had to
be followed.  And I knew all of them, and followed all of them.
It was an interesting experience as I came to realize that there
were so many people out there who didn't know the rules, and
just assumed I was wrong.  I actually lost credibility for being
correct!! 

With language, the most common usage always eventually
becomes the new "correct" usage, and the old "correct" usage
fades away.  It's a self-healing set of rules.  As I said, I find
that fascinating.

OK, back to Django topics...

--Fred
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/27/14 9:00 PM, Mark Phillips wrote:
Fred,

My apologies if my comment about "or" and "nor" offended you. That was not my intent. 

Thanks,

Mark


On Mon, Jan 27, 2014 at 9:49 AM, Fred Stluka <fred@bristle.com> wrote:
Mark,

Most likely your Apache server is running as user "apache" in
group "apache", and your Django code is being called by the
Apache server via WSGI, so it is also running as user "apache".

True?

If so, make sure that the files and directories needed by the
Apache and Django code are all accessible to user "apache".

P.S.  "or" vs "nor" -- Yeah, I have a VERY strong background in
English grammar.  Partly because it was beaten into me by
the nuns, and party because I'm such a fundamentally nerdy
engineer type that I found the technique of "diagramming a
sentence" to be fascinating and even fun. 

So, I know the difference between an adjective and an adverb,
can cite things like the "present perfect tense", know what a
"dangling participle" is and that you are not supposed to end
a sentence with a preposition, etc.  

But, the vast majority of people I meet seem to agree  with
Churchill that such rules are things "up with which we shall
not put" [1], so I rarely correct anyone any more, and have
come to recognize that language is a living evolving thing. 
The most common usage is by definition the correct usage,
despite what it says in the Oxford English Dictionary (six
inches thick), "Warriner's English Grammar and Composition",
or the "MLA Handbook" -- all sitting within reach of me
right now).

[1] http://public.wsu.edu/~brians/errors/churchill.html

In fact, I pretty much avoid ever using "nor" or "whom"
because people notice when I do, and change their opinion
of me slightly away from hard-hitting, down-to-earth
engineer, and towards ivory tower academic.

Also, I decided many years ago to never use a full sentence
when a simple phrase will do.

Anyhow, good luck with your Django/WSGI setup!

Any more problems, speak up.


--Fred
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/27/14 11:01 AM, Mark Phillips wrote:
Fred,

Thanks for your help. I made some progress so far.

1. I discovered that I fogot to add the port 7000 to Apache´s ports.conf.

2. The Apache error logs were in /var/log/apache2/error.log and not in /var/log/apache2/mom/error.log. APACHE_LOG_DIR was not set.

2. Once I found the error logs, I found this - 
 
[Sun Jan 26 06:25:04.325511 2014] [:warn] [pid 3472] mod_wsgi: Compiled for Python/2.7.5+.
[Sun Jan 26 06:25:04.325576 2014] [:warn] [pid 3472] mod_wsgi: Runtime using Python/2.7.6.

I tried removing mod-python as recommended by the django docs, but that did not help. So I removed the Debian package for python-wsgi and compiled python-wsgi myself. 

I am not at the point where I get Forbidden - You don have permission to access /mom/inventory on this server. This is progress!! ;) 

I guess the current problem is that I cannot run the django app from a user account (/home/django/). I added the user django to the group www-data, but I still get the forbidden message. I will try moving it to /var/www as you have it set up. 

Thanks again!

Mark

P.S. I got a good chuckle from your signature block - "Open Source: Without walls and fences, we need no Windows or Gates." A small nit, but I believe it should read ..., we need no Windows nor Gates... to be grammatically correct.


On Sun, Jan 26, 2014 at 7:43 PM, Fred Stluka <fred@bristle.com> wrote:
Mark,

I'm doing this fine with Django 1.4.2 and Python 2.7.3.

My wsgi.py file looks like:


import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()



My Apache config looks like:



# WSGI setup, for use by Django and other Python webapps
# See notes in:
#  - http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
#  - http://code.google.com/p/modwsgi/wiki/ConfigurationIssues
#  - https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi
# --Fred 11/22/2012
WSGIPythonHome /var/python27/virtualenvs/hhl
<Directory "/var/www/wsgi-bin">
    Order allow,deny
    Allow from all
</Directory>
WSGIDaemonProcess wsgi_apps processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup  wsgi_apps
WSGIScriptAlias   /mypythonapp "/var/www/wsgi-bin/mypythonapp.wsgi"
WSGISocketPrefix  run/wsgi

#
# hhlweb Django app
#
<Directory "/var/www/django/hhlweb/apache">

    Order deny,allow
    Allow from all
</Directory>
WSGIDaemonProcess hhlweb processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup  hhlweb
# Note: Support both aliases for backward compatibility with release 1.
WSGIScriptAlias /hhlweb /var/www/django/hhlweb/apache/django.wsgi
WSGIScriptAlias /       /var/www/django/hhlweb/apache/django.wsgi

# Map the Django STATIC_URL to the Django STATIC_ROOT
<Directory /var/www/django/hhlweb/collected_static>

    Order deny,allow
    Allow from all
</Directory>
Alias /static/ /var/www/django/hhlweb/collected_static/

# Map the Django MEDIA_URL to the Django MEDIA_ROOT
<Directory /var/www/django/hhlweb/media>

    Order deny,allow
    Allow from all
</Directory>
Alias /media/ /var/www/django/hhlweb/media/



Hope this helps!
--Fred
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/26/14 5:15 PM, Mark Phillips wrote:
I have my first django app running using runserver. I am now trying to get Apache to serve my site. I have read the django docs and quite a few other references on the Internet, but I cannot get Apache to do anything with my django site. And no error message.

I am running django 1.6 in a virtual environment with Python 2.7 on Debian Linux inside my LAN. 

Configuration file for apache
/etc/apache2/sites-enabled/mom.conf:
<VirtualHost *:7000>
    ServerName beagle
    ServerAlias beagle
    ServerAdmin mark@beagle
    
    DocumentRoot /var/www/mom

    WSGIScriptAlias /mom /home/django/django_projects/inventory/inventory_project/wsgi.py

    <Directory /home/django/django_projects/inventory/inventory_project>
        Order deny,allow
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/mom/error.log
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/mom/access.log combined
</VirtualHost>

/home/django/django_projects/inventory/inventory_project/wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "inventory_project.settings.dev")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

The project layout:
/home/django/django_projects/
└── inventory
    ├── fabfile2.py
    ├── fabfile.py
    ├── inventory
    │   ├── admin.py
    │   ├── admin.py~
    │   ├── admin.pyc
    │   ├── forms.py
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── migrations
    │   ├── models.py
    │   ├── models.py~
    │   ├── models.pyc
    │   ├── templates
    │   ├── templatetags
    │   ├── tests.py
    │   ├── urls.py
    │   ├── urls.py~
    │   ├── urls.pyc
    │   ├── views.py
    │   ├── views.py~
    │   └── views.pyc
    ├── inventory_project
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── media
    │   ├── settings
    │   ├── settings.py
    │   ├── settings.py~
    │   ├── settings.pyc
    │   ├── settings.py.old
    │   ├── static
    │   ├── urls.py
    │   ├── urls.py~
    │   ├── urls.pyc
    │   ├── wsgi.py
    │   └── wsgi.pyc
    ├── manage.py
    ├── mom
    ├── Notes.txt
    ├── README
    └── requirements.txt

/etc/apache2/mods-enabled/wsgi.conf
 WSGIPythonPath /home/django/django_projects/inventory:/home/django/.virtualenvs/inventory_project/lib/
python2.7/site-packages/

Any ideas on why I only get "Ooops cannot connect to beagle:7000/mom"?

Thanks,

Mark
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2O1ZfrsbywQWW9XSK5iEkybkMd4B%2B9Rxdi0bQC_Zzc%2BNA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52E5C7E1.4060802%40bristle.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2M4dNV%2B-SXvx%3DpfNH9UJ7pJgc7b%2BENK8CVfncqffCbxRA%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52E68E20.9060401%40bristle.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2O069QeAaUv%3D92GZfZE-JYQ0EeBstmryKYs3o%3DTgUosVA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment