在Apache或Nginx中将请求数据发送到PHP,可以使用FastCGI模块。下面是Apache和Nginx的配置示例:
首先,确保已安装并启用了mod_fastcgi模块。
在Apache的配置文件(如httpd.conf)中添加以下行:
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiExternalServer /path/to/php-fcgi -host 127.0.0.1:9000
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fcgi
Alias /php-fcgi /path/to/php-fcgi
Options +ExecCGI
SetHandler fastcgi-script
Require all granted
上述配置将把以.php结尾的请求发送到PHP FastCGI服务器。
在Nginx的配置文件(如nginx.conf)中添加以下行:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
上述配置将把以.php结尾的请求发送到PHP FastCGI服务器。
在上述配置中,需要确保FastCGI服务器的主机和端口与实际的PHP FastCGI服务器配置相匹配。