gpt4 book ai didi

django - 错误 : Target WSGI script not found or unable to stat when run django on apache

转载 作者:行者123 更新时间:2023-12-04 13:34:04 25 4
gpt4 key购买 nike

我在 apache 上运行 django 时遇到问题:

htdocs/blog/apps/homepage/urls.py:

url(r'^$', 'index', name="h_index"),
url(r'^about/$', 'about', name="h_about"),
url(r'^contact/$', 'contact', name="h_contact"),
url(r'^archive/$', 'archive', name="h_archive"),

htdocs/博客/urls.py
(r'^', include('apps.homepage.urls')),

django.wsgi:
import os
import os.path
import sys

sys.path.append('D:/Coding/xampp/htdocs')
sys.path.append('D:/Coding/xampp/htdocs/blog')

os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'

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

httpd.conf:
Alias /static/ "D:/Coding/xampp/htdocs/blog/static/"
WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi"

当我运行“本地主机/博客”时,它正在工作。但是运行“localhost/blog/about/”或其他,它是错误的:
[error] [client ::1] Target WSGI script not found or unable to stat:   .../htdocs/blog/django.wsgiabout, referer: http://localhost/blog/

最佳答案

请注意您的 apache 配置如何与 mod_wsgi 的 WSGIScriptAlias 的文档语法不匹配。
WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi"
应该:
WSGIScriptAlias /blog "D:/Coding/xampp/htdocs/blog/django.wsgi"
(注意第二个标记“/blog”之后没有斜杠)

我刚刚解决了同样的问题,并在谷歌上找到了这个线程。希望这对您和 future 的用户有所帮助。

想要查询更多的信息:

  • http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
  • http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
  • 关于django - 错误 : Target WSGI script not found or unable to stat when run django on apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9483800/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com