Home >Backend Development >PHP Tutorial >Example of coexistence of PHP3 and PHP4_PHP tutorial

Example of coexistence of PHP3 and PHP4_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:07:58868browse

The author has been debugging programs in the php3 environment. Later, after switching to php4, I felt that there were many problems.
Mainly because some programs that used to run normally under php3 suddenly discovered that there were a lot of problems under php4.
But when the program originally used in php4 moved to php3, it said that the xx function was not defined or that the syntax of a certain function was incomplete. Then I suddenly thought: Can I install both? It's also a good idea to test the compatibility of the program with both.


The installation and instruction document of php4/3 that the author refers to does not specify the method. It probably only says that the two can achieve coexistence through the --enable-versioning command and DSO mode. So what kind of DSO is it? After the author repeatedly thought about the installation and configuration practices for n times, I finally successfully installed both into the same web server. All .php3 files are parsed by php3, and .php files are parsed by php4.


Principle of implementation:

To achieve the coexistence of two different versions of parsers, the enable-versioning directive must be used. When should it be used? This depends on which version of the parser is installed later, so this command only needs to be used during subsequent installations. That is to say, if you install php4 first (as is the case in this example) and then php3, then you must add the enable-versioning directive when configuring php3. The reverse is also true.


The following are the installation and configuration steps:

1. Considering that the author's own system is installed with php4 and uses static mode, so if you want to use DSO, you can only It is adopted by php3. But when is enable-versioning added? Since there is no clear explanation in the document, I can only test it myself. I won’t go into details here about the configuration instructions for installing apache.


2. First compile and install php4 in a static way. The main instructions are as follows:

./configure --with-mysql=/www/mysql --with-apache= ../apache_1.3.12
> --enable-track-vars

3. Note: After compiling and installing php4, you must first install apache, otherwise install and install in DSO mode in the next step There is no way to use apxs script when compiling php3. And what should be noted!!!! is that when configuring apache, you must add the --enable-shared=max directive (that is, use the dso method) and then compile and install apache.


4. Finally, configure and compile php3. After decompression, run:

./configure --with-mysql=/www/mysql --with-apxs=/www/httpd/bin/apxs
> --enable-versioning
make
make install

  Under normal circumstances, there is basically no problem.
If the reader is using an older php4 such as php4rc1, it may appear that the contents of the php4rc1 directory are not compiled but only the contents of the php3 directory are compiled during compilation. Then a solution is to change the directory of php4rc1 after compiling php4. Name, that's fine.


Test: Generally, as long as the compilation and installation pass smoothly, you only need to modify the settings of php3 and php4 in httpd.conf, and then restart apache.


Create two files test.php and test.php3 in the htdocs directory. Under normal circumstances, calling test.php will display the content of php4 and calling test.php3 will display the content of php3.
The content of test.php/test.php3 is as follows:

phpinfo();


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629889.htmlTechArticleThe author has been debugging the program in the php3 environment. Later, after switching to php4, I felt that there were many problems. Mainly because some programs that used to run normally under php3 suddenly found a lot of problems under php4...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn