改变Php的处理程序名称

在我的apache服务器上,我想同时运行多个版本的PHP,以便根据项目的需要轻松切换它们。 我注意到一些提供多个版本的PHP的共享托pipe提供者需要你在.htaccess定义你需要的PHP版本:

 AddHandler application/x-httpd-php5 .php 

我想在我的服务器上实现这样的事情,以便我可以轻松切换PHP版本:

 AddHandler application/xhttpd-php53 .php # .. or .. AddHandler application/xhttpd-php54 .php # .. or .. AddHandler application/xhttpd-php55 .php 

不过,我编译的所有PHP版本都有一个名为application/xhttpd-phpphp5-script的处理application/xhttpd-php 。 我试图search一个./configure标志,允许您更改这些处理程序名称,但没有出现。

我search了PHP的github回购这两个 string ,这就是我发现:

  • /sapi/apache2filter/sapi_apache2.c 行 )
  • /sapi/apache2handler/sapi_apache2.c 行 )
  • /main/php.h 行 )
  • /sapi/apache/mod_php5.c 行 )
  • /sapi/apache_hooks/mod_php5.c 行 )

用新的处理程序名称和版本号replace这些string是否安全,还是有更广泛的使用(实际logging的ora)方法来更改处理程序名称?

你可以使用一个PHP版本作为模块,另一个版本作为CGI。 如果你需要在特定的项目(vhost)中使用特定的PHP版本,你可以使用类似的东西

 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /vhosts/php55.example.net/ ServerName php55.example.net ScriptAlias /php-fastcgi/ /usr/local/php-5.5.1/bin/ AddHandler php-fastcgi .php AddType application/x-httpd-php .php Action php-fastcgi /php-fastcgi/php-cgi <Directory /vhosts/php55.example.net> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /vhosts/php54.example.net/ ServerName php54.example.net ScriptAlias /php-fastcgi/ /usr/local/php-5.4.17/bin/ AddHandler php-fastcgi .php AddType application/x-httpd-php .php Action php-fastcgi /php-fastcgi/php-cgi <Directory /vhosts/php54.example.net> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>