(reproduced) PHP 4 and PHP 5 coexist

Source: Internet
Author: User
Recently to use the new PHP5, but do not want to affect the original PHP4, so found a lot of coexistence methods, but are not ideal, and finally
Found a better article, speaking of the use of Apache to achieve coexistence, with different ports, very convenient, is reproduced as follows

Download PHP 4 for Windows Zip binary package, unzip to any directory (I extracted to e:php), the inside of the php.ini-dist renamed to PHP.ini. Copy php.ini and Php4ts.dll to the Windows installation directory.

Download PHP 5 for Windows Zip binary package, unzip to any non-PHP 4 directory (I extracted to e:php5), the inside of the php.ini-dist renamed to PHP.ini.

Modify the Apache2. httpd.conf file below. The key to the modification is to use the Ifdefine directive: Find the Code:

Listen 80

This line, revision changed to

Code: Listen Listen Bayi

Add at the end of httpd.conf

Code:

LoadModule php4_module "E:/php/sapi/php4apache2.dll"

LoadModule php5_module "E:/php5/php5apache2.dll" Phpinidir "E:/php5/php.ini"

AddType application/x-httpd-php. php addtype application/x-httpd-php. php3 addtype application/x-httpd-php. PhP4 AddType application/x-httpd-php. php5 addtype application/x-httpd-php-source. Phps

Other directives, such as DirectoryIndex and Adddefaultcharset, should be set by themselves.

The next step is to create two Apache services with different operating parameters. At the command prompt, go to the bin directory in the Apache2 installation directory and run the code:

Apache-k install-d php=php5-n APACHE2PHP5

This creates a new Apache service with php5 running parameters, named APACHE2PHP5.


Note that it is also important to copy the Php5ts.dll under the PHP5 directory to C:\Winnt\System32
Then start the APACHE2PHP5 service and restart the Apache2 service, which you can start in the management tools--services, or using Apache 2 's Monitor Apache Servers.

Accessing http://localhost/is PHP 4, and accessing http://localhost:81/is using PHP 5.

  • 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: info-contact@alibabacloud.com 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.