PHP-FPM 不是 运行 在 OS X Mojave 下的 Nginx 上
PHP-FPM not running on Nginx under OS X Mojave
我从 Mac 上的 Sierra 升级到 Mojave,升级并安装了 php-fpm (php)、nginx 并写道在新配置中。
PHP 没有解析 php 代码,我可以在 header 上看到它是 运行 PHP,甚至日志也显示了它.但是,当它呈现页面时,它是空白的。也没有有用的日志。
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
目前获得了以下内容(全部通过 Homebrew 安装)。
- PHP7.3.1
- 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 代码的原因可能是什么?
确保 ~.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
相关
如果页面是空白的,很可能 PHP 中有错误。用输出当前配置的简单内容替换 PHP 页面:
<?php phpinfo();
如果可行,您就知道问题出在您的PHP。
我从 Mac 上的 Sierra 升级到 Mojave,升级并安装了 php-fpm (php)、nginx 并写道在新配置中。
PHP 没有解析 php 代码,我可以在 header 上看到它是 运行 PHP,甚至日志也显示了它.但是,当它呈现页面时,它是空白的。也没有有用的日志。
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
目前获得了以下内容(全部通过 Homebrew 安装)。
- PHP7.3.1
- 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 代码的原因可能是什么?
确保 ~.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
相关如果页面是空白的,很可能 PHP 中有错误。用输出当前配置的简单内容替换 PHP 页面:
<?php phpinfo();
如果可行,您就知道问题出在您的PHP。