如何在安装相同的apache的情况下同时使用PHP 4和5?

时间:2022-08-10 16:55:18

I am trying to make this feature available, maybe in an apache .htaccess file.

我试图使这个功能可用,也许在一个apache .htaccess文件中。

5 个解决方案

#1


1  

I used the virtual server config to setup several folders with PHP5 and some with PHP4 on my PC to test code. I also set them up with different hostnames (also in the windows host file). (I dont have access to that machine anymore, but here is what I remember.)

我使用虚拟服务器配置来设置PHP5的几个文件夹,并在我的PC上使用PHP4来测试代码。我还使用不同的主机名(也在Windows主机文件中)设置它们。 (我再也无法访问那台机器,但这是我记得的。)

Just include one of the following (for linux)

只需包含以下其中一项(适用于linux)

AddHandler php4 .php
Action php4 /cgi-bin/php4

or

AddHandler php5 .php
Action php5 /cgi-bin/php5

in the virtual server config.

在虚拟服务器配置中。

If you want to use them for the same (virtual) server, one of the file extensions would have to be renamed to .php5, .php4 or similar.

如果要将它们用于同一(虚拟)服务器,则必须将其中一个文件扩展名重命名为.php5,.php4或类似名称。

#2


0  

My understanding is that everything in PHP 4 is in PHP 5, so if you install PHP 5 and configure it, you will be able to use all features in both 4 and 5.

我的理解是PHP 4中的所有内容都是PHP 5,因此如果您安装PHP 5并对其进行配置,您将能够使用4和5中的所有功能。

#3


0  

Just use the CGI binarys. Or recompile PHP5 with X feature.

只需使用CGI二进制文件。或者使用X功能重新编译PHP5。

#4


0  

My web host (1&1) does this; to use php5 I have to use .php5 extensions or add an .htaccess command to use php5 for my .php files.

我的网络主机(1和1)执行此操作;使用php5我必须使用.php5扩展或添加.htaccess命令来使用php5作为我的.php文件。

I would think it's simply a matter of installing php4 and php5 to separate directories and telling apache to interpret .php files with php4 and .php5 files with php5.

我认为这只是将php4和php5安装到单独的目录并告诉apache使用php5解释带有php4和.php5文件的.php文件的问题。

#5


0  

If you are using a control panel application on your server such as cPanel, this can probably already handle this for you.

如果您在服务器上使用控制面板应用程序(如cPanel),则可能已经为您处理了此问题。

If you are on a bare server, simply have PHP 5 run using one method (e.g. DSO) and have PHP 4 run using a different method (e.g. SuPHP). You can then use a .htaccess file to determine which version of PHP to use or just have .php for PHP 5 and .php4 for PHP 4 files.

如果您使用的是裸机服务器,只需使用一种方法(例如DSO)运行PHP 5,并使用不同的方法(例如SuPHP)运行PHP 4。然后,您可以使用.htaccess文件来确定要使用的PHP版本,或者只有.php用于PHP 5,而.php4用于PHP 4文件。

However, there is a huge overlap between PHP 4 and PHP 5. The only major difference I can think of offhand that one would likely encounter is XML processing.

但是,PHP 4和PHP 5之间存在巨大的重叠。我可以想到的唯一一个可能遇到的主要区别是XML处理。

#1


1  

I used the virtual server config to setup several folders with PHP5 and some with PHP4 on my PC to test code. I also set them up with different hostnames (also in the windows host file). (I dont have access to that machine anymore, but here is what I remember.)

我使用虚拟服务器配置来设置PHP5的几个文件夹,并在我的PC上使用PHP4来测试代码。我还使用不同的主机名(也在Windows主机文件中)设置它们。 (我再也无法访问那台机器,但这是我记得的。)

Just include one of the following (for linux)

只需包含以下其中一项(适用于linux)

AddHandler php4 .php
Action php4 /cgi-bin/php4

or

AddHandler php5 .php
Action php5 /cgi-bin/php5

in the virtual server config.

在虚拟服务器配置中。

If you want to use them for the same (virtual) server, one of the file extensions would have to be renamed to .php5, .php4 or similar.

如果要将它们用于同一(虚拟)服务器,则必须将其中一个文件扩展名重命名为.php5,.php4或类似名称。

#2


0  

My understanding is that everything in PHP 4 is in PHP 5, so if you install PHP 5 and configure it, you will be able to use all features in both 4 and 5.

我的理解是PHP 4中的所有内容都是PHP 5,因此如果您安装PHP 5并对其进行配置,您将能够使用4和5中的所有功能。

#3


0  

Just use the CGI binarys. Or recompile PHP5 with X feature.

只需使用CGI二进制文件。或者使用X功能重新编译PHP5。

#4


0  

My web host (1&1) does this; to use php5 I have to use .php5 extensions or add an .htaccess command to use php5 for my .php files.

我的网络主机(1和1)执行此操作;使用php5我必须使用.php5扩展或添加.htaccess命令来使用php5作为我的.php文件。

I would think it's simply a matter of installing php4 and php5 to separate directories and telling apache to interpret .php files with php4 and .php5 files with php5.

我认为这只是将php4和php5安装到单独的目录并告诉apache使用php5解释带有php4和.php5文件的.php文件的问题。

#5


0  

If you are using a control panel application on your server such as cPanel, this can probably already handle this for you.

如果您在服务器上使用控制面板应用程序(如cPanel),则可能已经为您处理了此问题。

If you are on a bare server, simply have PHP 5 run using one method (e.g. DSO) and have PHP 4 run using a different method (e.g. SuPHP). You can then use a .htaccess file to determine which version of PHP to use or just have .php for PHP 5 and .php4 for PHP 4 files.

如果您使用的是裸机服务器,只需使用一种方法(例如DSO)运行PHP 5,并使用不同的方法(例如SuPHP)运行PHP 4。然后,您可以使用.htaccess文件来确定要使用的PHP版本,或者只有.php用于PHP 5,而.php4用于PHP 4文件。

However, there is a huge overlap between PHP 4 and PHP 5. The only major difference I can think of offhand that one would likely encounter is XML processing.

但是,PHP 4和PHP 5之间存在巨大的重叠。我可以想到的唯一一个可能遇到的主要区别是XML处理。