【发布时间】:2021-04-25 23:05:15
【问题描述】:
看起来像重复?不,不是!
这些是我的配置:
- 操作系统:Fedora 33 服务器
- PHP:PHP 7.4.13
- MySQL:MySQL 8.0
我会像这样在我的服务器上设置 WordPress:
- Nginx 面向互联网。
- Nginx 将请求传递给 PHP-fpm。
- PHP-fpm 然后处理之后的所有事情。
一切似乎都运行良好,但我不知道到底发生了什么?从字面上看,任何类型的主题都不起作用。我尝试了很多主题,但似乎都没有效果。
看一下页面:https://blog.harshrathod.dev
我收到了这个奇怪的警告,并且样式根本不生效:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "<URL>".
(index):29 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-includes/css/dashicons.min.css?ver=5.6".
(index):30 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-includes/css/admin-bar.min.css?ver=5.6".
(index):31 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-includes/css/dist/block-library/style.min.css?ver=5.6".
(index):32 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-includes/css/dist/block-library/theme.min.css?ver=5.6".
(index):33 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-content/themes/twentynineteen/style.css?ver=1.8".
(index):34 Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://php.harshrathod.dev/wp-content/themes/twentynineteen/print.css?ver=1.8".
这是我的 nginx 配置:
root /usr/share/wordpress;
location / {
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:4000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
【问题讨论】:
-
它可能是重复的。当找不到文件时,您将请求发送到
/index.php,它总是以test/html响应(这很好,因为这就是漂亮的永久链接的工作方式)。问题是找不到这些文件 - 可能是因为它们丢失、读保护,或者 Nginx 没有正确配置来定位它们。 -
好的,我已经提供了我的 nginx 配置。你能在这里找到什么奇怪的东西吗?
-
该配置将请求发送到 PHP,PHP 以
text/html的形式响应“拒绝访问”。您应该首先将location更改为location ~ \.php$,以便将非PHP 文件视为静态文件。完整的配方是documented here。 -
好的,这解决了我的问题。谢谢!