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 how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

What is the full form of PHP?What is the full form of PHP?Apr 28, 2025 pm 04:58 PM

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

How does PHP handle form data?How does PHP handle form data?Apr 28, 2025 pm 04:57 PM

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

What is the difference between PHP and ASP.NET?What is the difference between PHP and ASP.NET?Apr 28, 2025 pm 04:56 PM

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

Is PHP a case-sensitive language?Is PHP a case-sensitive language?Apr 28, 2025 pm 04:55 PM

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

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 Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools