小编Say*_*han的帖子

Nginx - Rails上的Wordpress博客使用mime类型的text/html加载样式和脚本

我刚刚在一个Rails应用程序的/ blog目录下安装了一个Wordpress博客,在Unicorn和Nginx上运行,当我访问我的domain.com/blog页面时,我的样式表和脚本没有在浏览器中正确加载.Chrome控制台给出了以下错误:

  • 资源解释为样式表,但使用MIME类型text/html进行传输
  • 资源解释为脚本,但使用MIME类型text/html进行传输

一直在试图解决这个问题并在SO上尝试了很多解决方案,但仍然无法通过...似乎需要在我的Nginx配置上进行一些更改,特别是对于blog/php位置.这是我的配置:

upstream unicorn {
  server unix:/tmp/unicorn.domain.sock fail_timeout=0;
}

server {
  server_name www.domain.com;
  return 301 $scheme://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; …
Run Code Online (Sandbox Code Playgroud)

php wordpress ruby-on-rails nginx mime-types

10
推荐指数
2
解决办法
1036
查看次数

标签 统计

mime-types ×1

nginx ×1

php ×1

ruby-on-rails ×1

wordpress ×1