我发现只有两个用于C++的FastCGI库.有"官方"和fastcgi ++.一个人比另一个人好吗?还有其他人存在吗?
我之前没有遇到过这个问题,直到我更改了php.ini上的include路径,希望能够上传到docroot之外的目录.当我遇到"未指定输入文件"时.错误我把它改回了默认的php.ini,现在它不会消失!
关于可能发生的事情的任何想法?
我的理解kernel.terminate是它在响应返回给客户端后触发.
在我的测试中,看起来并非如此.如果我sleep(10)在kernel.terminate中调用了一个函数.浏览器也等待10秒钟.处理似乎在发送响应之前发生.
我在配置中有以下内容:
calendar:
class: Acme\CalendarBundle\Service\CalendarService
arguments: [ @odm.document_manager, @logger, @security.context, @event_dispatcher ]
tags:
- { name: kernel.event_subscriber }
Run Code Online (Sandbox Code Playgroud)
我的订阅者类:
class CalendarService implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array(
'kernel.terminate' => 'onKernelTerminate'
);
}
public function onKernelTerminate()
{
sleep(10);
echo "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
这似乎与Symfony没有发送Content-Length标题有关.如果我生成它,响应将正确返回.
// app_dev.php
...
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
// --- START EDITS ---
$size = …Run Code Online (Sandbox Code Playgroud) 我在php-fpm上运行PHP 5.5/5.6实例没有任何问题(unix套接字和nginx).
今天我编译了PHP 7,并将其作为第三个PHP实例启动.虽然PHP 7实例的PHP 5.5/5.6实例的请求得到了很好的服务,但我得到了:
警告:pid 2582,fpm_request_check_timed_out(),第277行:[pool www0] child 2813,script''(request:"")执行超时(120.018160 sec),终止
在我的php-fpm日志文件中
[error] 1889#0:*4 recv()失败(104:对等连接重置)从上游读取响应头,客户端:xxx.xxx.xxx.20,server:localhost,request:"GET /info.php HTTP/1.1",上游:"fastcgi:// unix:/var/run/php70-fpm.sock:",主机:"xxx.xxx.xxx.21"
在我的nginx错误日志文件中.
我使用的fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name也适用于PHP 5.6实例.虽然PHP 7的脚本文件名似乎是空的.我在请求一个脚本/info.php.
使用php-fpm使用PHP 5.x和7.0之间有什么区别吗?
UPDATE
至少我不是唯一一个正面临这些问题的人.我在这里打开了一个错误报告:https://bugs.php.net/bug.php?id = 69850
还有一个非常相似(可能相同)的bug已在此处报告:https://bugs.php.net/bug.php?id = 69875(thx to @crypticツ)
更新2
尝试最新的alpha2.那里的错误是固定的.Unix套接字现在再次像魅力一样工作.
我正在寻找一种方法来使用PHP脚本来控制对Apache资源的访问.我希望拥有不依赖于目标资源的访问控制; 即它将适用于html,文件,其他脚本和cgi程序,就像"允许来自"或"拒绝来自"指令一样 - 除了使用自定义逻辑.
我已经看了几种方法来尝试管理它:
鉴于FastCGI的普及,其中#2看起来最有前途,也是最便携的.所以,我设法换掉了通常的linux php模块,让php通过fastcgi工作.它比在Windows上更难,但最终作为外部服务器工作,即使用Apache指令
FastCGIExternalServer /var/www/html/thing -host 192.168.0.11:9000
并启动php守护进程
php-cgi -q -b 192.168.0.11:9000 &
试图找到一种使用FastCgiAccessChecker调用PHP脚本的方法遇到了麻烦.
我尝试过各种方法尝试通过更改FastCGIExternalServer和/或FastCgiAccessChecker指令中的文件名来传递我想要运行的脚本名称 - 不起作用.我也尝试用脚本说明符启动php-cgi,即
php-cgi -q -b 192.168.0.11:9000 -f /var/www/html/thing/access.php &
什么都行不通.我可以告诉apache识别我的指令,因为当我包含FastCgiAccessChecker然后访问一个php页面时,内容类型更改为text/plain,如果它是一个脚本,我会从页面服务中丢失第一个~8000字节的内容(否)想法为什么).但它不会调用我想运行的PHP脚本.
据我所知,发生的事情是FastCgiAccessChecker假定指定的fastcgi服务器专门编译为充当访问检查器.没有办法告诉fastcgi服务器(在我的情况下是PHP)运行什么脚本来进行访问检查.
我在网上搜索过,据我所知,没有人曾尝试过使用PHP脚本,或者没有人写过.
所以我的问题是:我该怎么做?我可以看到一些可能性:
1)我遗漏了一些东西,并且有一些神奇的方法让FastCgiAccessChecker做我想做的事:运行PHP脚本来控制apache访问控制
2)我在c中编写自己的FastCGI服务器并嵌入PHP,因此我可以指定我想要运行的PHP脚本(我花了几分钟时间查看它;它看起来很复杂和可怕,我没有在c中工作自1995年以来)
3)我放弃了FastCGI并编写了一个apache模块来直接调用我的PHP脚本来控制访问.(看起来也很复杂;而且这种技术需要为每个执行PHP的请求生成一个新进程.)
有没有人有任何建议,无论是如何让FastCGI做我想要的,或者是(合理地)简单替代FastCGI?
感谢你能提出的任何建议
我有一个运行fastcgi/PHP的NGINX服务器.我需要添加用户名,但我无法让PHP执行文件 - 它只是问我是否要下载它.它在没有userdir的情况下工作(例如,它适用于physibots.info/hugs.php,但不适用于physibots.info/~kisses/hugs.php).
配置:
server {
listen 80;
server_name physibots.info;
access_log /home/virtual/physibots.info/logs/access.log;
root /home/virtual/physibots.info/public_html;
location ~ ^/~(.+?)(/.*)?\.php$ {
fastcgi_param SCRIPT_FILENAME /home/$1/public_html$fastcgi_script_name;
fastcgi_pass unix:/tmp/php.socket;
}
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
autoindex on;
}
location ~ \.php$ {
try_files $uri /error.html/$uri?null;
fastcgi_pass unix:/tmp/php.socket;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用本教程在我的新Web服务器上安装nginx,php和mysql.
本教程使用的是ISPConfig 3,可以选择使用FastCgi还是PHP-FPM.
我想知道哪两个更好.在性能和速度方面,哪两个最适合与nginx一起使用?
顺便说一句,我在服务器上也启用了memcached和xcache.
有谁知道如何在MAMP/MAMP Pro上增加apache fastCGI超时?我到处都看,但似乎无法找到它.
任何帮助一如既往地受到赞赏.
谢谢,Codarz360
我最近安装了Windows Subsystem Ubuntu shell,并将我的所有开发从XAMPP转移到通过ubuntu windows子系统安装的nginx和php7.0-fpm.
我面临的问题是php文件加载速度极慢.对于测试我简单地说
<?php phpinfo(); ?>
Run Code Online (Sandbox Code Playgroud)
在一个文件中并执行它.字面上,系统花了两分钟才回复.我调试了很多,但找不到任何解决方案.
我通过nginx服务器块运行nginx并设置了我的本地域.
我确信通过观察如果我加载一个静态文件即txt或html文件,它会加载速度非常快.
下面是我的网站启用文件和nginx conf文件..
网站已启用
server {
listen 80 ;
listen [::]:80;
root /mnt/c/xampp/htdocs/doit/;
index index.html index.php;
server_name doit.dev www.doit.dev;
error_log /var/log/nginx/error.log;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 120;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
Nginx配置文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在共享主机(Bluehost)上运行Django.我正在使用需要PIL的功能.PIL从交互式shell导入和工作,但是在我的fcgi进程中,它从PIL导入映像中的MemoryError崩溃.任何有关为什么它可能在fcgi内失败的帮助将非常感激.
__Environment Info__:
Python2.7
Local installs of libjpg, zlib, freetype, and lcms
Virtualenv:
Django 1.3, PIL, flup, etc.
__Stack Trace__:
File ".../feincms_thumbnail.py", line 3, in <module>
from PIL import Image
File ".../PIL/Image.py", line 45, in <module>
\__import__("FixTk")
File ".../python2.7/lib-tk/FixTk.py", line 15, in <module>
import ctypes
File ".../python2.7/ctypes/__init__.py", line 549, in <module>
CFUNCTYPE(c_int)(lambda: None)
__.fcgi__:
<!-- language: python -->
# setup paths
# set DJANGO_SETTINGS_MODULE in os.environ
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
Run Code Online (Sandbox Code Playgroud)