PHP4 and PHP5 coexist in a system _php technique

Source: Internet
Author: User
Tags save file
PHP4 and PHP5 coexist in a system

An article that is seen elsewhere is a bit older, and these two days are also trying to find a time to use Iis+apache to do two PHP coexistence .... Then send it again. Read the text.

The benefits are not much said,:D The downside ... Is the CGI way (quote official Original: We consider installing PHP like this Suicidal.--esayr Note: E Wen is not good? Ah, the last one is suicide meaning)
Say less, look directly at the method:

First, this article deals with the extremely version of software:
Apache 1.3.28 for WIN
Microsoft Internet Server Information (IIS6)
PHP 4.3.3 (4.3.5), PHP 5.0.0 Beta (5.0.0RC1)
MySQL 3.23.57 (3.23.58)

Two, the general steps: (two, three optional)

1. Install each version of PHP separately

2. Install Apache, set Apache and PHP

3. Install IIS and set up PHP versions in IIS [Note 1]

4. Install MySQL

Third, pre-installation preparation:
Copy the required program to each folder, this article according to the following directory structure, you can modify the ^ ^ according to the need:


To the C:/WINNT/SYSTEM32/DRIVERS/ETC (XP is c:/windows/system32/drivers/etc) folder, locate the Hosts file (no?! @_@ so ...:D), add below PhP4 # Waiter PHP 4 php5 # Waiter PHP 5

Roar ... If you understand ~ ~ Modify Other names yourself 8D We continue ...
Save File ...

Four, install each version of PHP
Suppose you have downloaded each version of PHP you need ... (which download??:P find it yourself ...)
Here take 4.3.3 and 5.0.0-beta for example ... (4.3.5vs5.0.0rc1 I tried, too. If it's not the same as your environment don't blame me:(, much the same, think about it yourself);)

㈠ installation PHP4.3.3
① Unzip the download file (:) Earth people know)
② will copy PHP4.3.3 Php.exe, php.ini-recommended, Phpêmbed.lib, Php4ts.dll, Php4ts.lib, Dll/*.* and Extensions/*.* to c:/httpd/ PHP4
③ Modify php.ini-recommended:
Extension_dir = "c:/httpd/php4/extensions/"
Cgi.force_redirect = 0
Save As PHP.ini (just under c:/httpd/php4/)

㈡ installation PHP5. 0.0BETA
① decompression ...
② copies Php.exe, php.ini-recommended, Phpêmbed.lib, Php4ts.dll, Php4ts.lib, Dll/*.* and extensions/*.* to c:httpd PHP5
If it is PHP5. 0.0rc1, then there is no DLL and extensions directory, only ext--is extensions pull
If... You are a loyal user of MySQL, and don't forget to handcuff Libmysql.dll to the past [note 2].
③ Modify php.ini-recommended:
Extension_dir = "c:/httpd/PHP5/extensions/"
Cgi.force_redirect = 0
If it is php4.0.0rc1, then Extension_dir = "c:/httpd/PHP5/ext/"
Save As PHP.ini (just in c:/httpd/PHP5/below)

Five, configure Apache
Open c:/httpd/apache/conf/httpd.conf and append some settings below:

<virtualhost *:80>
ServerAdmin test@php433
ServerName PHP4
Serveralias www
DocumentRoot "C:/httpd/www"
<directory "C:/httpd/www" >
Options Indexes followsymlinks MultiViews
AllowOverride None
Order Allow,deny
Allow from all
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php4/php.exe"

<virtualhost *:80>
ServerAdmin test@php500
ServerName php5
DocumentRoot "C:/httpd/www"
<directory "C:/httpd/www" >
Options Indexes followsymlinks MultiViews
AllowOverride None
Order Allow,deny
Allow from all
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php5/php-cgi.exe"

Six, about PHP5 and MySQL
MySQL installation, I will not say more, their own under the Install bar ... (Skip this paragraph, no problem?)
You can load MySQL by modifying the php.ini ... (Sad ...)

Seven, test ...
Start Apache (if httpd.conf configuration is wrong, there will be error prompts ...), then the address bar input http://php4 and http://php5 start PHP4 and PHP5 respectively ... Is it cool? :D:D:D [Note 3]
I believe that for the vast number of PHP programmers, and want to learn PHP5 and do not want to give up PHP4 comrades, this will be a good way. ENJOY it!

To sum up:
In fact, the idea is very simple, the use of CGI to achieve PHP4 and PHP5 coexistence. I found a lot of information, this is the simplest and most practical. But only for everyone to play this machine, do not do so on the server ... Otherwise ~ Consequence ego ... Don't look for me.

If you have problems with the above method, you can try other ways, here is a list of some foreign success stories:

Interested can continue to study under ...

To continue one of the important additions to this programme:

PHP4 and PHP5 coexist, there is a problem of php.ini conflict ...
As you all know, the general practice is to copy php.ini to the System folder (C:winnt or c:windows). If multiple versions are installed at the same time, it is bound to cause conflicts ...

In fact, if you read the PHP installation document carefully, there will be the following text:
Does Where C I cut to could the php.ini? The php.ini files are only searched in two places:1) in your Apache installation directory (e.g. C:apacheapache) 2) in R%SYSTEMROOT% Directory.

And we're just using the first way ... (Is it the official expectation that this is the case??) GOD knows ...)

I tested successfully in the above environment ... If you are having trouble, you can leave a message or discuss it with the discussion area.

I'm not very good at writing tutorials and stuff like that. I read it, but it is not easy for others to understand, we have to be patient.
Although the process is relatively simple, but it took me a lot of time (there are two places ...). I was looking for the wrong information, and I was miserable, this big a testified to pull ... (:D Big a sleeps to go to the toilet, I still in ... Here is not suitable for children, delete 500 words)

PHP5 era is getting closer and faster, and quickly understand ...

[Note 1]:
Originally wanted to write for IIS ... But I really don't want to install a useless thing on my machine (:(to me), so ... The title column, but gave up writing ... To some spectators say sorry ...

[Note 2]:
Here said Han: in PHP5. 0.0rc1, do not know you see ext under a mysqli.dll, as well as php.exe under the same level of a libmysqli.dll? What is this? Actually, this is the official new version of MySQL. (4.1.0 seems to be ...) ) An upgrade for the high version of the MySQL player can try ... is said to support some new features of MySQL OH

[Note 3]:
When you start Apache, if you see "overlap on port 80" ... Do not worry, in the httpd.conf, the Namevirtualhost *:80 before the note to go ... (This place is difficult for me for a long time.) Only the Apache settings are not familiar. But this time counted the Apache set up to see all over, still have the harvest

Related articles
Apache 2.2.2 + PHP5.1.4 can not run the solution. -05-11 02:07 pm-click: 12651
php5.1.3 Release-05-03 09:41 pm-click: 1860
PHP5 Learning Notes--Classes and Objects in php5-09-05 02:13 pm-click: 5776
• Upgrade from php4.3.* to php5.0.0-08-09 01:49 am-click: 5136
Similarities and differences between PhP4 and php5-08-01 06:25 pm-click: 4260
Redhat 9 Configure APACHE2.0.50 +PHP5+MYSQL4.0.20+GD Library-07-29 02:00 am-click: 13784
php5 for Windows installation-07-14 10:33 pm-click: 13370
PHP5 Official edition issued yesterday--with PHP Research Handbook-07-14 10:04 PM-click: 6069
• PHP5 for object-oriented-06-25 07:13 pm-click: 3749
• PHP5 for object-oriented (1)-06-25 07:11 pm-click: 4488

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.