在当前服务器configuration正在运行FPM / FastCGI的情况下,如何运行某些脚本(这可以在apache conf中的虚拟主机或目录设置中)作为mod_php运行?
服务器操作系统:Ubuntu-Server 11.04
那么,简单的答案就是安装mod_php和php_fcgi ,而不要在任何configuration中定义x-application PHP处理程序。 然后它会使用mod_php 。
要使用mod_php和fastcgi运行PHP,还可以使用PHP-FPM和Apache mod_actions
为Apache安装mod_fcgi和mod_actions 。 安装并configurationPHP-FPM 。
并添加到虚拟主机configuration下面的块
<IfModule mod_fastcgi.c> <IfModule mod_actions.c> FastCGIExternalServer /var/www/<document_root_path>/php.fastcgi -socket /var/run/php-fpm.sock Action php-fcgi-script /php.fastcgi virtual <FilesMatch ".+\.ph(p[345]?|t|tml)$"> SetHandler php-fcgi-script </FilesMatch> </IfModule> </IfModule>
我更喜欢运行PHP-FPM监听UNIX套接字。
但是您也可以configuration您的PHP-FPM在本地端口上运行,所以您应该将-socketconfiguration参数更改为-host ip:port
FastCGIExternalServerconfigurationhttp://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer