drnxnbf199049
2019-02-11 07:40
浏览 89
已采纳

PHP-FPM没有在OS X Mojave下的Nginx上运行

I upgraded from Sierra on my Mac to Mojave and when upgraded and installed the php-fpm (php), nginx and wrote in a new config.

The PHP is not parsing the php code, I can see on the header that it's running PHP and even the logs shows it. But, when it renders the page, it's blank. No useful log as well.

curl -v localhost.test/info.php * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost.test (127.0.0.1) port 80 (#0)

GET /info.php HTTP/1.1 Host: localhost.test User-Agent: curl/7.54.0 Accept: / < HTTP/1.1 200 OK < Server: nginx/1.15.8 < Date: Mon, 11 Feb 2019 07:37:17 GMT < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < Connection: keep-alive < X-Powered-By: PHP/7.3.1 < * Connection #0 to host localhost.test left intact

[11-Feb-2019 15:21:30] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[11-Feb-2019 15:21:30] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[11-Feb-2019 15:21:30] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[11-Feb-2019 15:21:30] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[11-Feb-2019 15:21:30] NOTICE: fpm is running, pid 22336
[11-Feb-2019 15:21:30] NOTICE: ready to handle connections

And currently got the following (all installed via Homebrew).

  1. PHP 7.3.1
  2. NGINX 1.15.8

/usr/local/etc/nginx/nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    include servers/*;
}

/usr/local/etc/nginx/servers/localhost.conf

server {
    listen 80;
    server_name localhost.test;
    access_log  /usr/local/var/log/nginx/localhost.test.access.log;

    index index.php;

    root /Users/louie/Development/php;

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        include        fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
    }
}

What could be the cause why this it's not parsing the PHP code?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douji6667 2019-02-11 07:47
    已采纳

    Make sure the ~.php is correct.

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

    Also related to nginx showing blank PHP pages

    打赏 评论
  • dtqf81594 2019-02-11 09:06

    If the page is blank, there's most likely an error in the PHP. Replace the PHP page with something simple that outputs the current configuration:

    <?php phpinfo();
    

    If that works, you know the problem is with your PHP.

    打赏 评论