lighttpd 上的 Django:重定向到 .fcgi (404)
我正在将 django 项目部署到轻型服务器上。当我尝试访问网站根目录时,一切都很好,但是如果我添加 /admin/ 或 /blog/ 我得到:
Page not found (404)
Request Method: GET
Request URL: http://x.x.x.x/mysite.fcgi/mysite.fcgi/admin/
并且,
Page not found (404)
Request Method: GET
Request URL: http://x.x.x.x/mysite.fcgi/mysite.fcgi/blog/
我已经阅读了一些关于此问题的帖子,似乎可以通过添加来解决: FORCE_SCRIPT_NAME =“” 到设置.py。然而,这对我不起作用。
urls.py:
urlpatterns = patterns('',
(r'^$', index),
(r'^blog/$', blog_view),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
lighttpd.conf:
$HTTP["host"] == "x.x.x.x" {
server.document-root = "/home/lighttpd/sedin/web"
fastcgi.server = (
"/mysite.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
#"host" => "127.0.0.1",
#"port" => 3033,
"socket" => "/home/lighttpd/sedin/sedin.sock",
"check-local" => "disable",
#"fix-root-scriptname" => "enable", #also tried this, but didn't work
)
),
)
alias.url = (
"/static/admin/" => "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/",
"/media/" => "/home/lighttpd/sedin/media/",
"/static/" => "/home/lighttpd/sedin/web/static/",
)
url.rewrite-once = (
"^(/static.*)$" => "$1",
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/mysite.fcgi$1",
)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
添加到您的settings.py:
https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#forcing-the-url-prefix-to-a-preferrer-value
fix-root- scriptname
修复了使用fastcgi.server = ( "/"
而不是fastcgi.server = ( "/mysite.fcgi"
) 时的 lighttpd 错误Add to your settings.py:
https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#forcing-the-url-prefix-to-a-particular-value
fix-root-scriptname
fixes lighttpd bug when you usefastcgi.server = ( "/"
instead offastcgi.server = ( "/mysite.fcgi"
我通过终止所有正在运行的 fastcgi 进程并启动一个新进程解决了这个问题。我不知道每次更改项目 .py 文件时都必须重新启动 fcgi。
I solved this problem by killing all running fastcgi processes and starting a new one. I wasnt aware that fcgi had to be restarted everytime I made a change to the projects .py-files.
存在这样的票证: https://code.djangoproject.com/ticket/11694
There exist a ticket for this: https://code.djangoproject.com/ticket/11694