gpt4 book ai didi

Django、apache2、css 未显示...可能需要身份验证?

转载 作者:太空宇宙 更新时间:2023-11-03 17:22:29 25 4
gpt4 key购买 nike

运行 CentOS 6.4、Apache 2.2.15、Django 1.5。

User nobody
Group nobody

LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so
LoadModule alias_module modules/mod_alias.so
LoadModule authz_host_module modules/mod_authz_host.so
WSGIDaemonProcess project python-path=/var/www/project/
WSGIScriptAlias / /path/to/wsgi.py
WSGISocketPrefix run/wsgi

ErrorLog logs/error_log

Listen 80

Alias /static/ /path/to/static/

<Directory /static>
Satisfy Any
Allow from all
</Directory>

<Directory /path/to/wsgi.py>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

<Location ~ "/path/to/project/(css/*|images/*|style/*|js/*|)">
Satisfy Any
Allow from all
AuthType None
Require all granted
</Location>

我已经阅读了以下 SO 问题和回复,但我仍然收到“未加载样式表,因为它的 MIME 类型“text/plain”不是“text/css”。我在 HTML 中的引用文件指定“文本/css”:

Apache Config - Exclude Location from Authentication

css was not loaded because its MIME type, "text/html", is not "text/css". (我实际上无法让它工作。我遇到了各种语法错误)。

我不知道还能尝试什么。我正在猜测我的 httpd 配置文件中的某些内容不正确,但它是什么?

最佳答案

错误不是来自 HTML,而是来自 Apache 告诉您的客户端它所服务的文件是文本/纯文本类型(在 HTTP 响应 header 中)。您需要告诉 Apache 如何确定它所服务的文件的 MIME 类型。

您应该将这些指令添加到您的 httpd 配置中(在其他 LoadModule 指令之后的顶部应该没问题):

LoadModule mime_module modules/mod_mime.so
TypesConfig /etc/mime.types

更多详情:http://httpd.apache.org/docs/2.2/mod/mod_mime.html#typesconfig

关于Django、apache2、css 未显示...可能需要身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16092148/

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