Nginx Wordpress配置,主题目录中的PHP文件未传递给FastCGI

Nginx Wordpress配置,主题目录中的PHP文件未传递给FastCGI,php,wordpress,nginx,fastcgi,subdirectory,Php,Wordpress,Nginx,Fastcgi,Subdirectory,我是新的NGINX配置,所以请容忍我。以下是我的配置,适用于整个站点: server { listen ...; server_name funkyoslo.no; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/funkyoslo.webbr.org/html; index index.php inde

我是新的NGINX配置,所以请容忍我。以下是我的配置,适用于整个站点:

server {
listen ...;
server_name  funkyoslo.no;

#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
    root   /usr/share/nginx/funkyoslo.webbr.org/html;
    index  index.php index.html index.htm;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/funkyoslo.webbr.org/html/;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/funkyoslo.webbr.org/html/$fastcgi_script_name;
    include        fastcgi_params;
}
}
但是,我试图加载文件/wp content/themes/funkyoslo/load-songs.php,它给了我一个500内部服务器错误。我已经检查了错误日志,显然该文件根本没有传递给FastCGI

我尝试添加以下块,但无效:

location ~ .*/wp-content/themes/funkyoslo/.*\.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/funkyoslo.webbr.org/html/wp-content/themes/funkyoslo/$fastcgi_script_name;
    include         fastcgi_params;
}

非常感谢您的帮助

我不知道你的配置出了什么问题,但是试试这个,希望它能起作用,这是最小的配置

注释

  • 已删除服务器块级别的索引,请检查以了解原因
  • 已将根目录删除到服务器块级别,请检查以了解原因
  • 从php块级别删除了所有额外的配置,通过试用,我意识到我只需要我编写的这两个配置
  • http://
    添加到
    fastcgi\u pass
    ,我不知道是否真的需要它,但我习惯了这样写
编辑:好的,显然我不需要
http://
,我只是检查了一下

-


这给了我以下错误:[emerg]8088#0:上游主机无效“[error]8109#0:*1重写或内部重定向周期wh$Adding:
fastcgi\u param SCRIPT\u FILENAME$document\u root$fastcgi\u SCRIPT\u name;
似乎对根目录有帮助,但/wp content/themes/funkyoslo/load-songs.php的问题仍然存在。不管怎样,它现在可以工作了!显然我的php文件中有错误(由于我的pc和VPS上的php.ini不同),php-FPM错误日志中显示了这一点。我无法发现它,因为AJAX负载给我带来了500个内部服务器错误。我认为我的初始配置没有任何问题,尽管您现在为我提供了更好的设置,谢谢!)
server {
    listen 80;
    server_name  funkyoslo.no;
    root /usr/share/nginx/funkyoslo.webbr.org/html;
    error_page 500 502 503 504 /50x.html;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass http://127.0.0.1:9000;
    }
}