List Info

Thread: Apache and Django : 403 Forbidden




Apache and Django : 403 Forbidden
user name
2006-11-22 07:29:56
Hello,

I've finished my app using Django, and I'm now trying to
host it on a
dedicated server using Apache 2 and mod_python. But, I get a
"403
Forbidden" error from Apache on nearly all pages I want
to see.

The website is at the url : http://www.chibbi.fr.

The thing I don't understand, is that the main page
(http://www.chibbi.fr.)
and the /chibbi/ page
(http://www.chibbi.fr/chi
bbi/) works, but the other no. You will see
the errors by clicking on any links.

And here is my configuration :
Apache/2.0.58 (Unix) mod_ssl/2.0.58 OpenSSL/0.9.7i
mod_python/3.1.4 Python/2.4.2

The django project name is chibbi and it folder is in
/home/chibbi/.

The database is MySQL.

The virtual host is the following one :

<VirtualHost *:80>
ServerName www.chibbi.fr
ServerAlias chibbi.fr

DocumentRoot /home/chibbi/
<Directory />
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "sys.path+['/home/chibbi']"
SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
PythonDebug On
</Directory>

Alias /static "/home/chibbi/chibbi/media"
<Location "/static">
SetHandler None
</Location>
</VirtualHost>

And my url.py file :
from django.conf.urls.defaults import *
from chibbi.club.feeds import LatestBlogEntries, PodCast,
EventsDateFeed

feeds = {
    'blog': LatestBlogEntries,
    'podcast': PodCast,
    'evenements': EventsDateFeed,
}


urlpatterns = patterns('',
    # Example:
    (r'^$', 'chibbi.club.views.index'),
    (r'^static/(.*)$', 'django.views.static.serve',
{'document_root':
'/home/cocoa/chibbi/media'}),
    (r'^chibbi/$', 'chibbi.club.views.chibbi'),
    (r'^pink-purple/$', 'chibbi.club.views.pink_purple'),
    (r'^contact/$', 'chibbi.club.views.contact'),
    #(r'^photos-videos/$',
'chibbi.club.views.photos_videos'),
   
(r'^photos-videos/(tag-(?P<tag>[a-zA-Z0-9-_]+)/)?(page
-(?P<page>[0-9]+)/)?$',
'chibbi.club.views.photos'),
   
(r'^photos-videos/(tag-(?P<tag>[a-zA-Z0-9-_]+)/)?(page
-(?P<page>[0-9]+)/)?((?:photo|video)-(?P<photo_id&g
t;[0-9]+)/)?$',
'chibbi.club.views.photos_detail'),
    (r'^flux/', 'chibbi.club.views.flux'),
    (r'^inscription/$', 'chibbi.club.views.register'),
    (r'^blog/$', 'chibbi.club.views.blog'),
    (r'^blog/(?P<title>[a-zA-Z0-9-_]+)/$',
'chibbi.club.views.blog_detail'),
    (r'^traiter-inscription/$',
'chibbi.club.views.process_register'),
    (r'^connexion/$', 'chibbi.club.views.login'),
    (r'^deconnexion/$', 'chibbi.club.views.logout'),
    (r'^evenements/$', 'chibbi.club.views.all_events'),
    (r'^evenements/(?P<event>[a-zA-Z0-9-_]+)/$',
'chibbi.club.views.event'),
   
(r'^evenements/inscription/(?P<event>[a-zA-Z0-9-_]+)/$
',
'chibbi.club.views.event_register'),
    (r'^lieux/$', 'chibbi.club.views.location_all'),
   
(r'^lieux/filtre-(?P<filter>[a-z0-9-_]+)/$','chibbi.cl
ub.views.location_all'),
    (r'^lieux/(?P<place_name>[a-zA-Z0-9-_]+)/$',
'chibbi.club.views.location'),

    (r'^profil/$', 'chibbi.club.views.profil'),
    (r'^profil/editer/$', 'chibbi.club.views.edit_profil'),
   
(r'^profil/password/','chibbi.club.views.edit_password'),
    (r'^profil/messages/$',
'chibbi.club.views.profil_messages'),
    (r'^profil/messages/(?P<id_message>[0-9]+)/$',
'chibbi.club.views.view_message'),

    (r'^clubbers/((?P<filtre>[a-zA-Z0-9-_]+)/)?$',
'chibbi.club.views.clubber'),
   
(r'^clubber/(?P<clubber_login>[a-zA-Z0-9-_.]+)/$','chi
bbi.club.views.clubber_details'),
   
(r'^clubber/(?P<clubber_login>[a-zA-Z0-9-_.]+)/ecrire/
$',
'chibbi.club.views.write_messages'),

    # Newsletter
   
(r'^newsletter/desinscription/(?P<type>(clubber|contac
t))/(?P<hash>[^/]+)/',
'chibbi.club.views.newsletter_unsubscribe'),

    # Uncomment this for admin:
    (r'^admin/', include('django.contrib.admin.urls')),

    # RSS
    (r'^rss/(?P<url>.*)/$',
'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),

    # XML
    (r'^playlist/$', 'chibbi.club.views.playlist'),

)

Does anyone have an idea on how to solve that problem ?

Thanks in advance.

-- 
Fabien SCHWOB
____________________________________________________________
_
Derrière chaque bogue, il y a un développeur, un homme qui
s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Apache and Django : 403 Forbidden
user name
2006-11-22 10:18:58


On Nov 22, 8:29 am, "Fabien Schwob"
<xphut...gmail.com> wrote:
> <Directory />
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> PythonPath "sys.path+['/home/chibbi']"
> SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
> PythonDebug On
> </Directory>

Shouldn't this read <Location
"/">...</Location>?

The difference is explained in these two documents:
http://httpd.apache.org/docs/2.0/mod/core.html#location
http://httpd.apache.org/docs/2.0/sections.html#file-a
nd-web

Cheers,
/k


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Apache and Django : 403 Forbidden
user name
2006-11-22 12:46:56
On 11/22/06, Karsten W. Rohrbach <karstenrohrbach.de> wrote:
> On Nov 22, 8:29 am, "Fabien Schwob"
<xphut...gmail.com> wrote:
> > <Directory />
> > SetHandler python-program
> > PythonHandler django.core.handlers.modpython
> > PythonPath "sys.path+['/home/chibbi']"
> > SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
> > PythonDebug On
> > </Directory>
>
> Shouldn't this read <Location
"/">...</Location>?
>
> The difference is explained in these two documents:
> http://httpd.apache.org/docs/2.0/mod/core.html#location
> http://httpd.apache.org/docs/2.0/sections.html#file-a
nd-web

I've change my configuration to :

ServerName www.chibbi.fr
ServerAlias chibbi.fr

DocumentRoot /home/chibbi/
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "sys.path+['/home/chibbi']"
SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
PythonDebug On
</Location>

Alias /static "/home/chibbi/chibbi/media"
<Location "/static">
SetHandler None
</Location>

But I still have the same problem.

-- 
Fabien SCHWOB
____________________________________________________________
_
Derrière chaque bogue, il y a un développeur, un homme qui
s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Apache and Django : 403 Forbidden
user name
2006-11-22 13:56:46
Duh!
You probably want to take out the <Location> bits for
the "/"
namespace, and configure the PythonHandler for the complete
VirtualHost. (Just remove the <Location "/">
and </Location> lines).

Also, your DocumentRoot should not be the same as your
python code
base, I think. At least this is what the manual
recommends...

Note to self: Don't write on mailing lists before first
coffee  Sorry
for the hassle.

Cheers,
/k


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Apache and Django : 403 Forbidden
user name
2006-11-23 12:28:22
On 11/22/06, Karsten W. Rohrbach <karstenrohrbach.de> wrote:
> Duh!
> You probably want to take out the <Location> bits
for the "/"
> namespace, and configure the PythonHandler for the
complete
> VirtualHost. (Just remove the <Location
"/"> and </Location> lines).
>
> Also, your DocumentRoot should not be the same as your
python code
> base, I think. At least this is what the manual
recommends...

Thanks, it was a problem with de DocumentRoot.

Now, I've a problem with the current directory. When I try
to open
files using a relative path, I get an IOError like on
http://chi
bbi.fr/photos-videos/photo-270/.
All the files I would like to access are in
/home/chibbi/chibbi/media.

It seems that changing the current directory (with
os.chdir('/home/chibbi/chibbi/')) it work, but I make the
project
dependant of the disk structure. I there a way to say to
Django to use
the project root (/home/chibbi/chibbi/ in my case).

Is there a way to change that ? I haven't found anything in
the
settings.py options.

Thanks in advance.

-- 
Fabien SCHWOB
____________________________________________________________
_
Derrière chaque bogue, il y a un développeur, un homme qui
s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )