我最近决定从Apache2切换到Nginx.我在CentOS服务器上安装了Nginx并设置了基本配置.当我尝试在浏览器(FF/Chrome)中加载我的网站时,我注意到没有加载css文件.我检查了错误控制台并看到了这条消息:
Error: The stylesheet http://example.com/style.css was not loaded because its MIME type, "text/html", is not "text/css".
我检查了Nginx配置,一切似乎都很好:
http {
include /etc/nginx/mime.types;
..........
}
Run Code Online (Sandbox Code Playgroud)
css文件的mime类型在/etc/nginx/mime.types中正确设置.
text/css css;
一切似乎配置得很好但我的css文件仍然没有加载.我没有解释.
另一件值得一提的事.最初我使用epel存储库安装了Nginx,我得到了一个旧版本:0.8 ...在我看来,我的问题是该版本中的一个错误所以我卸载了0.8版本,将nginx存储库添加到yum然后安装了最新版本:1.0. 14.我认为新版本将解决我的问题,但不幸的是它没有解决我的想法.
我感谢任何帮助.
配置文件:
/etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; …
Run Code Online (Sandbox Code Playgroud) 我的网站上出现以下错误:
Error: There are multiple templates named 'velvet'. Each template needs a unique name. 1b1a247fc034d5089f331ec9540138ff6afd5f39.js:75:306
The stylesheet http://webmill.eu/css/bootstrap.min.css was not loaded because its MIME type, "text/html", is not "text/css". webmill.eu
The stylesheet http://webmill.eu/css/font-awesome.min.css was not loaded because its MIME type, "text/html", is not "text/css". webmill.eu
The stylesheet http://webmill.eu/css/velvet.css was not loaded because its MIME type, "text/html", is not "text/css". webmill.eu
The stylesheet http://webmill.eu/css/custom.css was not loaded because its MIME type, "text/html", is not "text/css".
Run Code Online (Sandbox Code Playgroud)
在对无法加载4种CSS样式表的广泛研究之后,我遵循了一些指导,并尝试通过在nginx文件中进行更改(/
等/ nginx的/网站可用/ Webmill
),插入“ include …