PHP-FPM无法在OS X Mojave下的Nginx上运行

时间:2019-02-11 07:40:49

标签: php nginx macos-mojave

我从Mac上的 Sierra 升级到Mojave,升级并安装了php-fpm(php),nginx并编写了新配置。

PHP没有解析php代码,我可以在标题上看到它正在运行PHP,甚至日志也显示了它。但是,当它呈现页面时,它是空白的。也没有有用的日志。

  

curl -v localhost.test / info.php   *正在尝试127.0.0.1 ...   * TCP_NODELAY设置   *连接到localhost.test(127.0.0.1)端口80(#0)

     
    

GET /info.php HTTP / 1.1     主机:localhost.test     用户代理:curl / 7.54.0     接受: /         

[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

目前有以下内容(全部通过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;
    }
}

为什么它没有解析PHP代码是什么原因?

2 个答案:

答案 0 :(得分:0)

确保〜.php是正确的。

# 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;
    }

也与nginx showing blank PHP pages

有关

答案 1 :(得分:0)

如果页面空白,则很可能是PHP错误。用输出当前配置的简单内容替换PHP页面:

<?php phpinfo();

如果可行,您知道问题出在您的PHP。