Re: Difficulty getting Django working with Apache and mod_python

2008-10-21 Thread Graham Dumpleton



On Oct 22, 2:23 am, projecktzero <[EMAIL PROTECTED]> wrote:
> On Oct 20, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Mon, Oct 20, 2008 at 5:15 PM, projecktzero <[EMAIL PROTECTED]>wrote:
> > > I'm pretty new to Django. I'm having trouble getting my Django
> > > app/web-site to run under Apache2 and Mod_Python. I'm running Django
> > > 0.96. I installed Apache2 and Mod_Python and tested both, and they
> > > seem to work properly.
>
> > > In my http.conf, I have the following:
>
> > > 
> > >    Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/
> > > python2.3/site-packages/django'] + sys.path"
> > >    SetHandler python-program
> > >    PythonHandler django.core.handlers.modpython
> > >    SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
> > >    PythonDebug On
> > > 
>
> > > The file permissions appear to be correct.(apache owns the .py files
> > > and they are executable, the .html templates are all ready-only for
> > > the world.)
>
> > > Unfortunately, I get the following error:
>
> > > EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on
> > > sys.path? Does it have syntax errors?): No module named hwsw2.settings
>
> > > Does anyone have any ideas on what I did to mis-configure this?
>
> > First, you've got a space in the PythonPath setting in your Location
> > directive. Every example I've seen has no space there so I don't think a
> > space is allowed (though I did not actually verify that a space breaks
> > things).
>
> > Second you've specified 'hwsw2' in both the PythonPath and the SetEnv for
> > the settings module, so the file names that will be searched for are
> > /usr/local/apache2/htdocs/hwsw2/hwsw2/settings.py, etc.  If you are going to
> > specify the settings module as hwsw2.settings then
> > '/usr/local/apache2/htdocs', without the trailing hwsw2, needs to be on your
> > python path.  Whether you need both directories on the path depends on how
> > you import things in your code. If you always specify hwsw2 in your imports
> > than you don't need to have it be specified explicitly in the python path,
> > just its parent.
>
> > Third you don't need to specify anything under site-packages (site-packages
> > is automatically searched) in the PythonPath, so you should remove
> > '/usr/lib/python2.3/site-packages/django' from the PythonPath setting.
>
> > Karen
>
> Thanks Karen
>
> I had caught the PythonPath issue after sending the post. Here's what
> worked:
>
> 
>     PythonPath "['/usr/local/apache2/htdocs'] + sys.path"
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
>     PythonDebug On
> 

It is bad practice to put Django source code under Apache document
root (htdocs). If you do this and Apache gets misconfigured, you can
expose all your source code to the world, including any sensitive
information in it like database passwords.

Graham
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Difficulty getting Django working with Apache and mod_python

2008-10-21 Thread projecktzero



On Oct 20, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 20, 2008 at 5:15 PM, projecktzero <[EMAIL PROTECTED]>wrote:
> > I'm pretty new to Django. I'm having trouble getting my Django
> > app/web-site to run under Apache2 and Mod_Python. I'm running Django
> > 0.96. I installed Apache2 and Mod_Python and tested both, and they
> > seem to work properly.
>
> > In my http.conf, I have the following:
>
> > 
> >    Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/
> > python2.3/site-packages/django'] + sys.path"
> >    SetHandler python-program
> >    PythonHandler django.core.handlers.modpython
> >    SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
> >    PythonDebug On
> > 
>
> > The file permissions appear to be correct.(apache owns the .py files
> > and they are executable, the .html templates are all ready-only for
> > the world.)
>
> > Unfortunately, I get the following error:
>
> > EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on
> > sys.path? Does it have syntax errors?): No module named hwsw2.settings
>
> > Does anyone have any ideas on what I did to mis-configure this?
>
> First, you've got a space in the PythonPath setting in your Location
> directive. Every example I've seen has no space there so I don't think a
> space is allowed (though I did not actually verify that a space breaks
> things).
>
> Second you've specified 'hwsw2' in both the PythonPath and the SetEnv for
> the settings module, so the file names that will be searched for are
> /usr/local/apache2/htdocs/hwsw2/hwsw2/settings.py, etc.  If you are going to
> specify the settings module as hwsw2.settings then
> '/usr/local/apache2/htdocs', without the trailing hwsw2, needs to be on your
> python path.  Whether you need both directories on the path depends on how
> you import things in your code. If you always specify hwsw2 in your imports
> than you don't need to have it be specified explicitly in the python path,
> just its parent.
>
> Third you don't need to specify anything under site-packages (site-packages
> is automatically searched) in the PythonPath, so you should remove
> '/usr/lib/python2.3/site-packages/django' from the PythonPath setting.
>
> Karen

Thanks Karen

I had caught the PythonPath issue after sending the post. Here's what
worked:


PythonPath "['/usr/local/apache2/htdocs'] + sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
PythonDebug On

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Difficulty getting Django working with Apache and mod_python

2008-10-20 Thread Karen Tracey
On Mon, Oct 20, 2008 at 5:15 PM, projecktzero <[EMAIL PROTECTED]>wrote:

>
> I'm pretty new to Django. I'm having trouble getting my Django
> app/web-site to run under Apache2 and Mod_Python. I'm running Django
> 0.96. I installed Apache2 and Mod_Python and tested both, and they
> seem to work properly.
>
> In my http.conf, I have the following:
>
> 
>Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/
> python2.3/site-packages/django'] + sys.path"
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
>PythonDebug On
> 
>
> The file permissions appear to be correct.(apache owns the .py files
> and they are executable, the .html templates are all ready-only for
> the world.)
>
> Unfortunately, I get the following error:
>
> EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on
> sys.path? Does it have syntax errors?): No module named hwsw2.settings
>
> Does anyone have any ideas on what I did to mis-configure this?
>
>
First, you've got a space in the PythonPath setting in your Location
directive. Every example I've seen has no space there so I don't think a
space is allowed (though I did not actually verify that a space breaks
things).

Second you've specified 'hwsw2' in both the PythonPath and the SetEnv for
the settings module, so the file names that will be searched for are
/usr/local/apache2/htdocs/hwsw2/hwsw2/settings.py, etc.  If you are going to
specify the settings module as hwsw2.settings then
'/usr/local/apache2/htdocs', without the trailing hwsw2, needs to be on your
python path.  Whether you need both directories on the path depends on how
you import things in your code. If you always specify hwsw2 in your imports
than you don't need to have it be specified explicitly in the python path,
just its parent.

Third you don't need to specify anything under site-packages (site-packages
is automatically searched) in the PythonPath, so you should remove
'/usr/lib/python2.3/site-packages/django' from the PythonPath setting.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Difficulty getting Django working with Apache and mod_python

2008-10-20 Thread projecktzero

I'm pretty new to Django. I'm having trouble getting my Django
app/web-site to run under Apache2 and Mod_Python. I'm running Django
0.96. I installed Apache2 and Mod_Python and tested both, and they
seem to work properly.

In my http.conf, I have the following:


Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/
python2.3/site-packages/django'] + sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings
PythonDebug On


The file permissions appear to be correct.(apache owns the .py files
and they are executable, the .html templates are all ready-only for
the world.)

Unfortunately, I get the following error:

EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on
sys.path? Does it have syntax errors?): No module named hwsw2.settings

Does anyone have any ideas on what I did to mis-configure this?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---