오늘 전체 프로덕션 서버에서 django를 구성하려고했습니다. 나는 mod_python을 사용한다. http : //beta.example.com을 열었을 때 사이트가 보이지만 http : //beta.example.com/admin 및 http : //beta.example.com/441/abc/가 작동하지 않습니다.Django + mod_python + apache : admin 패널 및 url이 작동하지 않습니다.
Page not found (404)
Request Method: GET
Request URL: http://beta.example.com/admin
{'path': u'admin'}
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Page not found (404)
Request Method: GET
Request URL: http://beta.example.com/441/abc/
{'path': u'441/abc/'}
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
내 URL을 :
from settings import MEDIA_ROOT
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# static files
url(r'^static/javascripts/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': MEDIA_ROOT + '/javascripts'}, name='javascripts'),
url(r'^static/images/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': MEDIA_ROOT + '/images'}, name='images'),
url(r'^static/stylesheets/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': MEDIA_ROOT + '/stylesheets'}, name='stylesheets'),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': MEDIA_ROOT}, name='static'),
(r'^admin/', include(admin.site.urls)),
url(r'^/?$', 'content.views.index', name='root-url'),
url(r'^(?P<id>[0-9]{2,5})/(?P<slug>[a-z\-]+)/?$', 'content.views.show', name='show-url'),
)
아파치 :
DocumentRoot "/var/www/django/beta.example.com/site"
<Location "/">
allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE site.settings
PythonOption django.root/
PythonDebug On
PythonPath "['/var/www/django/beta.example.com', '/var/www/django/beta.example.com/site'] + sys.path"
</Location>
<Location "/static" >
SetHandler none
</Location>
나는 무엇이 잘못되었는지 모르겠어요.
좋아요! 고마워요 :) –
그게 효과가 있지만 옳은 방법은'django.root'를 사용하여 URL을 제거하는 것입니다. 장고가 시작될 부분 만 남겨두면 사이트를 이동할 수 있고'django 만 변경하면됩니다. 루트'. 여기에 설명되어 있습니다 : http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs – laurent
미안 해요 내 대답은 슬라이스지만 멈춰야했습니다 .. 보완하기 위해, 귀하의 경우에은' /'만약 당신이 그것을 떼어 내면, 그것은 빈 상태를 유지하고 의사는 처음부터 적어도'/'를 남겨 두어야한다고 말했기 때문에 아마 그 행을 삭제했을 것입니다, 아마도 더 좋은 방법이있을 것입니다 ... 그러나 이것은 작동하는 것처럼 보입니다! –
laurent