所以简而言之,我试图让PHP脚本通过unix套接字侦听请求,并从另一个PHP脚本发送请求。 我已经配置了PHP-FPM:
<filesystem>
还有另一个PHP-FPM配置文件有效地监听[a]
; Unix user/group of processes
user = www
group = www
listen = /var/run/php-fpm-a.sock
;listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0660
; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 3
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 500
; host-specific php ini settings here
php_admin_value[open_basedir] = /usr/local/www/a
php_flag[display_errors] = on
/usr/local/www/a contains the following index.php:
<?php
echo 'test\ntest\ntest\n';
和Nginx指向它(这个位工作正常),这包含/var/run/php-fpm-b.sock
中的以下代码:
/usr/local/www/b/index.php
显然我在/usr/local/www/b/index.php中有问题,因为我得到的是&#34; TEST B&#34;作为输出。我不认为这是一个套接字权限问题,因为它会说错误,我的猜测echo 'TEST B';
$fp = fsockopen('unix:///var/run/php-fpm-a.sock', -1, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET /index.php HTTP/1.1\r\n";
$out .= "Host: localhost\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
是错误的,但是不知道PHP会接收什么。任何帮助将不胜感激。
注意:在FreeBSD11上使用PHP7