search
HomeBackend DevelopmentPHP TutorialPHP4 and PHP5 coexist in one system_PHP tutorial

PHP4和PHP5共存于一系统

在其它地方看到的一篇文章,老了一点,这两天也正想找个时间来用IIS+APACHE使用不同端口来做两个PHP共存....到时再发出来'罢..看原文吧

-------------------------------------------------------------
好处不多说了,:D 坏处嘛...是CGI方式的(引用官方原文:we consider installing PHP like this suicidal.--esayr注:E文不好?呵,最后一个是自杀的意思)
废话少说,直接看方法:

一,本文涉及软件极其版本:
Windows 2000 Professional/XP
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)


二,大致步骤:(二,三任选)

1.分别安装各版本的PHP

2.安装APACHE,设置APACHE 和 PHP

3.安装IIS,并在IIS中设置PHP各版本[注1]

4.安装MYSQL


三,安装前准备:
将所须程序COPY至各文件夹,本文按照以下目录结构进行,你可以根据需要自行修改^^:


C:/httpd/Apache
C:/httpd/MySQL
C:/httpd/PHP4
C:/httpd/PHP5
C:/httpd/php-includes
C:/httpd/phpMyAdmin
C:/httpd/tmp
C:/httpd/www

到C:/WINNT/system32/drivers/etc(XP是C:/WINDOWS/system32/drivers/etc)文件夹下,找到hosts文件(没有?! @_@ 那么.... :D ),在底下增加

127.0.0.1 php4 # Waiter PHP 4
127.0.0.1 php5 # Waiter PHP 5


吼吼...如果你懂~~自己修改其他名字吧 8D 我们继续...
保存文件...


四,安装各版本PHP
假设你已经下载你需要的各版本PHP...(哪下载?? :P 自己找吧...)
这里以4.3.3和5.0.0-beta为例...(4.3.5vs5.0.0RC1我也试了.如果和你环境不一样不要怪我 :( ,大同小异,自己琢磨吧) ;)

㈠安装PHP4.3.3
①解压缩下载文件(:) 地球人都知道)
②将PHP4.3.3中的php.exe, php.ini-recommended, phpêmbed.lib, php4ts.dll, php4ts.lib, dll/*.* 和 extensions/*.* 拷贝到C:/httpd/PHP4
③修改php.ini-recommended:
extension_dir = "C:/httpd/PHP4/extensions/"
cgi.force_redirect = 0
保存为php.ini(就在C:/httpd/PHP4/下)

㈡安装PHP5.0.0BETA
①解压缩...
②将php.exe, php.ini-recommended, phpêmbed.lib, php4ts.dll, php4ts.lib, dll/*.* 和 extensions/*.*拷贝至C:httpdPHP5
如果是PHP5.0.0RC1,那么没有dll和extensions目录,只有ext--就是extensions拉
如果...你是mysql的忠实用户,别忘了把libmysql.dll也拷过去[注2].
③修改php.ini-recommended:
extension_dir = "C:/httpd/PHP5/extensions/"
cgi.force_redirect = 0
如果是PHP4.0.0RC1,那么extension_dir = "C:/httpd/PHP5/ext/"
保存为php.ini(就在C:/httpd/PHP5/下)


五,配置APACHE
打开C:/httpd/Apache/conf/httpd.conf,在底下追加一些设置:


ServerAdmin test@php433
ServerName php4
ServerAlias www
DocumentRoot "C:/httpd/www"

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all

ScriptAlias /php4/ "C:/httpd/php4/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php4/php.exe"



ServerAdmin test@php500
ServerName php5
DocumentRoot "C:/httpd/www"

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all

ScriptAlias /php5/ "C:/httpd/php5/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"

六,关于PHP5和MYSQL
MYSQL的安装,我就不多说了,自己下了装吧...(跳过这段没意见吧? )
你可以通过修改php.ini,来加载MYSQL... (难过...)

七,测试...
启动APACHE(如果httpd.conf配置有错,会有出错提示...),然后地址栏输入http://php4和http://php5就分别启动PHP4和PHP5咯...爽吗? :D :D :D [注3]
相信对广大PHP程序员,以及想学PHP5又不想放弃PHP4的同志来说,这会是个不错的方法.ENJOY IT!

总结一下:
其实思路很简单,利用CGI方式实现PHP4和PHP5的共存.我找了很多资料,这个算最简单最实用了.不过只适合大家本机玩,千万别在服务器上这么搞...否则~后果自负...别找我

如果你按上面方法有问题,可以尝试其他途径,这里罗列一些国外的成功案例:
http://wiki.coggeshall.org/37.html
http://www.circle.ch/blog/p1387.html
http://www.schlitt.info/applications/blog/..._5_prallel.html

有兴趣的可以继续学习下...


继续关于本方案的一点重要补充:

PHP4和PHP5共存,存在一个php.ini冲突的问题...
大家都知道,一般做法是需要将php.ini复制到系统文件夹下(C:WinNT or C:Windows).如果同时安装多版本,势必会造成冲突...

其实,如果大家仔细阅读PHP安装文档,会有如下一段文字:
Does Where C I cut to could the php.ini? The php.ini files is only searched in two places: 1) in your Apache installation directory (e.g. c:apacheapache) 2) in your %SYSTEMROOT% directory.

而我们正是使用的第一种方式...(是不是官方早料到有这种情况??GOD KNOWS...)

我在上述环境下测试成功了...如果你遇到困难可以留言或到讨论区一起讨论。

结语:
偶不太会写教程之类的东东...自己看了懂,却不是很容易让别人理解,大家只好忍让了.
虽然过程比较简单,不过费了我不少时间(有两个地方...我找的资料有误,把我害惨了),这个大A作证拉...( :D 大A睡了一觉起来上厕所,我还在...此处少儿不宜,删去500字)

PHP5时代越来越近,赶紧深入了解去吧...

-------------------------------------------------------------------------
[注1]:
本来想写FOR IIS的...可实在不想在自己机器上装个没用的东西(对我而言 :( ),so...标题列了,却放弃写了...对部分看客说声抱歉...

[注2]:
这里说点题外话:在PHP5.0.0RC1中,不知道大家看到ext下有个mysqli.dll,以及php.exe同层目录下有个libmysqli.dll么?奇怪这是干嘛的?其实这是官方针对MYSQL的新版(4.1.0好象是...吧)的一个升级,对于高版本MYSQL玩家可以试试...据说支持MYSQL一些新特性哦

[注3]:
在启动APACHE时,如果看到什么"overlap on port 80"...不要着急,在httpd.conf中,把NameVirtualHost *:80前的注释去了即可...(这个地方难了我好长时间...只怪APACHE设置不熟悉.不过这次算好好把APACHE的设置看了遍,还是有收获)


相关文章
• apache 2.2.2 + PHP5.1.4 不能运行的解决办法. - 05-11 02:07 pm - 点击: 12651
• PHP5.1.3发布 - 05-03 09:41 pm - 点击: 1860
• PHP5学习笔记 -- Classes and Objects in PHP5 - 09-05 02:13 pm - 点击: 5776
• 从PHP4.3.*升级到PHP5.0.0 - 08-09 01:49 am - 点击: 5136
• php4和php5的配置异同比较 - 08-01 06:25 pm - 点击: 4260
• redhat 9下配置APACHE2.0.50 +PHP5+MYSQL4.0.20+GD库 - 07-29 02:00 am - 点击: 13784
• php5 for windows 安装详解 - 07-14 10:33 pm - 点击: 13370
• PHP5正式版昨日发行--附PHP研究手册 - 07-14 10:04 pm - 点击: 6069
• 为面向对象而生的PHP5 之二 - 06-25 07:13 pm - 点击: 3749
• 为面向对象而生的PHP5 (1) - 06-25 07:11 pm - 点击: 4488

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316906.htmlTechArticlePHP4 and PHP5 coexist in one system. An article I saw elsewhere, a little old, these two days I am also trying to find a time to use IIS+APACHE to use different ports to make two PHPs coexist....I will send it out then...
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
Explain the concept of a PHP session in simple terms.Explain the concept of a PHP session in simple terms.Apr 26, 2025 am 12:09 AM

PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

How do you loop through all the values stored in a PHP session?How do you loop through all the values stored in a PHP session?Apr 26, 2025 am 12:06 AM

In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

Explain how to use sessions for user authentication.Explain how to use sessions for user authentication.Apr 26, 2025 am 12:04 AM

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.

Give an example of how to store a user's name in a PHP session.Give an example of how to store a user's name in a PHP session.Apr 26, 2025 am 12:03 AM

Tostoreauser'snameinaPHPsession,startthesessionwithsession_start(),thenassignthenameto$_SESSION['username'].1)Usesession_start()toinitializethesession.2)Assigntheuser'snameto$_SESSION['username'].Thisallowsyoutoaccessthenameacrossmultiplepages,enhanc

What are some common problems that can cause PHP sessions to fail?What are some common problems that can cause PHP sessions to fail?Apr 25, 2025 am 12:16 AM

Reasons for PHPSession failure include configuration errors, cookie issues, and session expiration. 1. Configuration error: Check and set the correct session.save_path. 2.Cookie problem: Make sure the cookie is set correctly. 3.Session expires: Adjust session.gc_maxlifetime value to extend session time.

How do you debug session-related issues in PHP?How do you debug session-related issues in PHP?Apr 25, 2025 am 12:12 AM

Methods to debug session problems in PHP include: 1. Check whether the session is started correctly; 2. Verify the delivery of the session ID; 3. Check the storage and reading of session data; 4. Check the server configuration. By outputting session ID and data, viewing session file content, etc., you can effectively diagnose and solve session-related problems.

What happens if session_start() is called multiple times?What happens if session_start() is called multiple times?Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

How do you configure the session lifetime in PHP?How do you configure the session lifetime in PHP?Apr 25, 2025 am 12:05 AM

Configuring the session lifecycle in PHP can be achieved by setting session.gc_maxlifetime and session.cookie_lifetime. 1) session.gc_maxlifetime controls the survival time of server-side session data, 2) session.cookie_lifetime controls the life cycle of client cookies. When set to 0, the cookie expires when the browser is closed.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools