首页 > 解决方案 > NGINX 不加载 css 文件(wordpress 实现)

问题描述

我目前正在尝试使用 nginx 在子域上实现 wordpress。

我已经安装了所有依赖项(php 7.2、mariadb、mysql)并进行了全部配置。

当我尝试访问该网站时,这是我得到的:

nginx 上的屏幕 wordpress

更明确地说:这是我为使用 wordpress 配置 nginx 所做的:

须藤纳米/etc/nginx/conf.d/location.conf

server{
   server_name subdomain.domain.fr;
   root /home/domain/wordpress/;
   location / {
      fastcgi_pass unix:/run/php/php7.2-fpm.sock;
      include fastcgi_params;
      index index.php index.html index.htm;
      try_files $uri $uri/ =404;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param SCRIPT_NAME $fastcgi_script_name;
   }
}

我的问题是,当我第一次使用 wordpress 网站时,我习惯于在页面上看到一些 CSS。当我检查此页面时,我可以看到 css 文件已包含在内,但未使用。我不明白为什么。我认为我有特权问题或其他任何问题,但这是我第一次将 nginx 与 wordpress 一起使用,所以我一定做错了什么:

加载失败

谢谢你的帮助

标签: phpwordpressnginx

解决方案


我找到了一个完美的解决方案:

添加这个解决了我所有的问题:

location ~* \.(?:css|js|map|jpe?g|gif|png)$ { }

谢谢你的帮助


推荐阅读