Mac nginx配置后,还是不能识别php

2020/08/11 01:37:34 [error] 1430#0: *48 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8093"

server {
        listen       8093;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host-20200718.access.log  main;
        error_log   logs/error-20200718.log;

        location / {
            root   /usr/local/var/www/wordpress;
            index index.php index.html index.htm;

        if (!-e $request_filename) {
               rewrite  ^(.*)$  /index.php?s=/$1  last;
              break;
            }
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /usr/local/var/www/wordpres;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
阅读 2.2k
2 个回答

你的PHP-FPM配置的对了吗?

nginx 的配置中,改一行,加一行试试

fastcgi_param SCRIPT_FILENAME  $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
新手上路,请多包涵

看下你的php-fpm.conf配置里的listen是否配置的这个127.0.0.1:9000

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题