大佬教程收集整理的这篇文章主要介绍了php – Nginx – Rails中的WordPress博客使用mime类型的文本/ html加载样式和脚本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚刚在Rails应用程序的一个/博客目录下安装了一个wordpress博客,它运行在Unicorn和Nginx上,当我访问我的domain.com/blog页面时,我的样式表和脚本在浏览器中没有被正确加载. Chrome控制台给我以下错误:@H_673_2@
>资源解释为样式表,但使用MIME类型text / html进行传输
>资源被解释为脚本,但是使用MIME类型的文本/ HTML转移@H_673_2@
一直在试图解决这个问题,在这里尝试了很多解决方案,但仍然无法通过…似乎需要改变我的Nginx配置,特别是对于博客/ php位置.这是我的配置:@H_673_2@
upstream unicorn {
server unix:/tmp/unicorn.domain.sock fail_timeout=0;
}
server {
server_name www.domain.com;
return 301 $scheR_653_11845@e://domain.com$request_uri;
}
server {
listen 80 default deferred;
server_name domain.com;
root /home/dcs/htdocs/domain/current/PUBLIC;
access_log /home/dcs/htdocs/domain/log/access.log;
error_log /home/dcs/htdocs/domain/log/error.log;
LOCATIOn /blog {
try_files $uri $uri/ /blog/index.php?$args;
}
LOCATIOn ~ \.php${
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILename home/dcs/htdocs/domain/$fastcgi_script_name;
include /etc/Nginx/fastcgi_params;
}
LOCATIOn ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control PUBLIC;
}
try_files $uri/index.html $uri @unicorn;
LOCATIOn @unicorn {
proxy_set_header X-ForWARDed-For $proxy_add_x_forWARDed_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
keepalive_timeout 10;
}
Syntax: types { ... }
Default:
types {
text/html html;
image/gif gif;
image/jpeg jpg;
}
Context: http,server,LOCATIOn
将MIME类型的文件扩展名映射到响应.扩展名不区分大小写.几个扩展可以映射到一个类型,例如:@H_673_2@
types {
text/css css;
application/javascript js;
application/json json;
}
资料来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#types
以上是大佬教程为你收集整理的php – Nginx – Rails中的WordPress博客使用mime类型的文本/ html加载样式和脚本全部内容,希望文章能够帮你解决php – Nginx – Rails中的WordPress博客使用mime类型的文本/ html加载样式和脚本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。