Plusieurs versions de PHP sur EasyPHP

4 02 2012

Quand on fait du développement web en local avec MAMP, EasyPHP ou encore WAMP, ça peut être pratique de disposer des plusieurs versions de PHP (4, 5.2 et 5.3 notamment).

EasyPHP ne permet pas de switcher entre différentes versions de PHP. Voici donc un petit tuto pour utiliser différentes versions de PHP en parallèle…

Avant tout, il faut savoir qu’il existe 2 façons “d’intégrer” PHP à Apache :

  • Module : PHP est chargé en tant que module Apache (comme le mod_rewrite par exemple).
    Le lien entre Apache et PHP se fait par un «handler». Sous Windows, ce handler est une DLL, et sur Unix c’est un fichier .so.
  • CGI (Common Gateway Interface) : il s’agit d’une interface permettant à Apache de déléguer la réponse à une requête HTTP à un programme, qui peut être un script PERL, un script Python, Ruby ou encore… PHP !
    Apache va en fait exécuter le programme PHP (ex: php.exe sous Windows) en lui passant tout un tas de paramètres relatifs à la requête HTTP.

Dans ce tutoriel, je vais vous présenter les 2 méthodes, qui vous allez le voir présentent chacune des avantages et des inconvénients.

Télécharger & installer PHP

Tout d’abord, allez chercher la version de PHP que vous voulez ajouter à EasyPHP sur le site officiel :

Pour l’exemple, je prends la dernière version de PHP 4 (

Dézippez l’archive à la racine du dossier d’installation d’EasyPHP : D:\EasyPHP5.2.10. Renommez le dossier avec un nom court, chez moi ça sera php4. Le répertoire D:\EasyPHP5.2.10\php4 contient maintenant PHP 4.

Reste à le connecter à Apache, c’est parti :

Méthode #1 : Module

C’est la méthode utilisée par défaut par EasyPHP pour relier Apache et PHP.

Pour cela vous avez besoin de la DLL (le handler) adaptée à votre version de PHP ET votre version d’Apache.

Normalement, PHP est fourni avec une collection de DLL pour plusieurs versions d’Apache. Ces DLL se trouvent dans le dossier sapi : D:\EasyPHP5.2.10\php4\sapi.

Ces DLL sont toujours nommées de la même manière : {version php}{version apache}.dll. Par exemple, le handler php4apache2.dll permet d’utiliser php4 avec apache2.0.

Seulement voilà, ma version d’EasyPHP utilise Apache 2.2, et la dll php4apache2_2.dll n’est pas dans le dossier sapi.
Mais c’est pas grave, on peut la trouver grâce à l’ami Google :

Il suffit donc de copier la bonne dll à la racine de votre dossier php : D:\EasyPHP5.2.10\php4\php4apache2_2.dll pour ma part.

Maintenant que vous avez copié le handler adapté, le plus dur est fait. Il ne reste plus qu’à éditer le fichier de configuration d’Apache (httpd.conf) pour lui dire de charger PHP 4 à la place de PHP 5 :

Commentez le module actuel pour le désactiver :

# LoadModule php5_module "${path}/php/php5apache2_2.dll"
# PHPIniDir "${path}/apache"

Et ajoutez cette ligne juste en dessous pour charger votre module :

LoadModule php4_module "${path}/php4/php4apache2_2.dll"

Voilà, maintenant ça fonctionne, vous pouvez vérifier le changement de version de PHP avec la fonction phpinfo(). Si vous avez une erreur, c’est probablement que vous n’avez pas choisi la bonne DLL.

Pour revenir à la version d’avant, modifiez httpd.conf pour charger l’ancien module.

L’avantage est que cette solution est simple à mettre en œuvre, et propre.
L’inconvénient, c’est que vous ne pouvez charger qu’un seul module PHP sur un serveur Apache. Pour switcher entre différentes versions de PHP il faut donc arrêter le serveur, modifier sa configuration (httpd.conf) et le relancer.

Méthode #2 : CGI

Seconde méthode maintenant : le script CGI.

Dans ce cas, pas besoin de DLL. Il faut juste définir certains paramètres dans le (ou les) virtualhost dans lequel vous souhaitez utiliser une version spécifique de PHP.

Il faut aussi ajouter la permission au programme php.exe, et définir un ScriptAlias (pour que ça soit plus pratique à écrire) :

ScriptAlias /php4/ "${path}/php4/"

# [...]

<Directory "${path}/php4/">
    <Files "php.exe">
        Allow from all

# [...]

<VirtualHost *:80>
    DocumentRoot "${path}/www"
    ServerName localhost

    AddHandler php4-script .php .html .htm
    Action     php4-script /php4/php.exe

L’avantage de cette seconde méthode est que vous pouvez avoir autant de versions de PHP que vous voulez (même si la configuration est plus complexe), il suffit de créer un Virtualhost à chaque fois.
Pour cela, vous pouvez jouer sur le port par exemple :

  • localhost:80 : php 5.2
  • localhost:804 : php 4
  • localhost:8053 : php 5.3

Par contre je ne sais pas s’il y a des inconvénients au niveau performance, peut-être que CGI est plus lent…

Mais de toute façon ça n’est pas important puisqu’il s’agit d’un serveur de développement, pas d’un serveur de production.

Partager :

Ces icônes sont des liens vers des sites de partage de signet sociaux où les lecteurs peuvent partager et découvrir de nouveaux liens.
  • Digg
  • Facebook
  • Digg -fr
  • Live
  • MisterWong Fr
  • Scoopeo
  • StumbleUpon
  • Technorati
  • Wikio FR



Et maintenant je fais quoi ?

Aucun commentaire

35 réponses à “Plusieurs versions de PHP sur EasyPHP”

1 03 2017
wedding reception (22:56:54) :

I have been exploring for a bit for any high quality articles or weblog posts in this sort of house .
Exploring in Yahoo I at last stumbled upon this site.

Reading this information So i am happy to show that I’ve an incredibly just right uncanny feeling I found out just what
I needed. I so much for sure will make sure to don’t disregard this
site and give it a look on a constant basis.

24 04 2017
bamboo knitting needles (08:47:28) :

I savour, cause I found exactly what I used to be taking a look for.
You have ended my four day lengthy hunt! God Bless you
man. Have a great day. Bye

25 05 2017
miracle system (17:32:53) :

Thesе are truly fantastic ideaѕ in on thhe toⲣic of blogɡing.
Yoou have touched some pleasant factors here. Any way kep up wrinting.

Here iѕ my weeb pаge: miracle system

29 05 2017
logo designer (11:58:01) :

There’s definately a great deal to know about this topic.
I really like all of the points you have made.

16 09 2017
news o'malley (03:25:31) :

On how he thinks his valuables were stolen since in deed he
the top return your dream, Constance stated it was probable that folks
from the gang that didn’t take part in your struggle could
possibly have sneaked in the room as the battle happening and made away along with his belongings.
Try to research before leaving your place on the lifestyle
in the location. Just finished watching Dabangg,
Abhinav Kashyap’s sterling debut performance.

16 09 2017
1 news telugu (03:30:38) :

” Not being a philosopher or perhaps a physicist, I’m not going to learn about that subject in print, but I can tell you that, from the marketing standpoint, the world wide web marketing effect for the business stated previously would be a big fat zero. In breaking news from The Age, it can be reported how the carbon tax will hit each and every Australian which has a hefty price tag of $40,000 by 2050 coming to a massive $1 trillion hit to the Australian economy. News keeps us touching political affairs not simply of our country but also of most on the world.

16 09 2017
newsoftserial.h (03:35:18) :

The Nokia X3 Red Mobile includes a MP3, MP4, e-AAC+, WMA video and audio files can be playable for the
cell. When similar situations arise all cars in front with the leader
may pass the pace car and tag onto the rear from the pack.
Politicians are those who make trouble and after that campaign against them.

16 09 2017
m World news amreli (03:41:23) :

It is heartbreaking for the sports lover to travel out of town at the time of airing from the match of the favorite
team. “We are closely watching those things of the sedition movement and many individuals who were preparing to disrupt the 11 February rallies were arrested,” he said.
However, he formed the habit of stopping “just for a drink or two” with friends after

30 09 2017
h bloger (06:58:35) :

Upcoming New Releases: Going with exactly the same concept above, when you
have an associate in radio or are only really ahead of the curve musically, you might develop a
site that lists and describes the upcoming new album releases.
The readers of the blog are obviously interested
in the general field of know-how in the blog. In affiliate marketing, website visitors
to some website is driven from another website or from email.

1 10 2017
sales pitches (14:51:24) :

Newsbloggers, for one, are filling out where traditional news print media are neglecting.
Become A Valued Blog Commenter: Share your personality, knowledge,
and enthusiasm with blogs. Little Known Ways To (blank)AAn intriguing headline that teaches you are sharing insider
information along with your reader.

3 10 2017
sex toys for women (09:42:41) :

Ηeya i’m for the pгimary tume here. I found this board and I to finhd
It really useful & it helpеd me out much. I’m hoping to present one thing again and һelp others sucxh
as you aided me.

10 10 2017
This is not for you (23:52:53) :

Veгy interesting poiunts you have observed, thank you for posting.

21 02 2018
Alamat togel (02:52:04) :

Undeniably believe that that you said. Your favourite justification seemed to be
at the web the easiest thing to take into accout of.
I say to you, I definitely get irked whilst other people consider issues that they just do not understand about.
You managed to hit the nail upon the top and defined out the entire thing with no need side effect , other people could take a signal.
Will probably be again to get more. Thank you

7 06 2018 (14:09:20) :

En temas de dinero tenemos la solución, ¡Consúltenos!

24 07 2018
mobite mp3 downlaod (07:21:03) :

Howdy I am so excited I found your webpage, I
really found you by mistake, while I was browsing on Yahoo for something else, Anyways I am here now
and would just like to say thanks for a incredible post
and a all round entertaining blog (I also love the
theme/design), I don’t have time to read it
all at the minute but I have book-marked it and also added in your RSS feeds,
so when I have time I will be back to read a lot more, Please do keep up the awesome work.

29 08 2018 (02:08:14) :

Excellent article! We will be linking to this particularly great article on our website.
Keep up the good writing.

8 12 2018 (15:33:23) :

I savor, result in I discovered exactly what I used
to be having a look for. You have ended my 4 day lengthy
hunt! God Bless you man. Have a nice day. Bye

31 12 2018
Land Management Chennai India (07:57:53) :

hi!,I like your writing very a lot! share we be in contact extra approximately your article on AOL?
I require an expert on this area to solve my problem.

Maybe that’s you! Having a look ahead to look you.

18 06 2019
Jual Obat Aborsi Cytotec Batam (13:29:15) :

I go to see every day a few web pages and blogs to read posts, however
this website offers feature based content.

3 07 2019 (03:10:02) :

It’s nearly impossible to find well-informed people for this subject,
but you sound like you know what you’re talking about!

29 07 2019
trend (16:20:42) :

The evaluation for the Scuba Diving Equipment
market will not be restricted only to traditional or emerging markets.
This is usually very useful in the event
you need to be taught trading or nonetheless learning but need to enhance your self by following an expert trader’s evaluation. Funny kitchen aprons are usually obtainable in stable darkish colors, consisting of
quotes and doodles in white. Lighting: Whoever said lights can both
be vibrant white or yellow and nothing more did not attempt to experiment a lot.
A mix of more than one such doodle may also be used to convey a joke
or message. Even more complicated, you may assume that the trend itself
is changing randomly over time. I was hoping that there was a method to preserve trend traces when slicing information on the dashboard.
Are you in a position to create a button or a toggle to add/take away trend strains from all pivot
charts in a dashboard?

8 08 2019
paraphrase my assignment (15:33:43) :

Simply wish to say your article is as surprising.
The clearness in your post is just nice and i can assume you are an expert on this subject.
Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post.
Thanks a million and please carry on the enjoyable work.

8 12 2019 (03:32:25) :

Everything is very open with a really clear description of the challenges.
It was definitely informative. Your site is extremely helpful.
Many thanks for sharing!

6 02 2020
"Does Liking Anal Play Mean I'm Gay?" (06:01:59) :

I amm buying somе saucy Christmas gifts for
mʏ partner and ԝanted tⲟ know ԝhether anyone has any experrience wіth Peaches and Screams UK boutique?
I really ᴡant to gett their French Maid Fantaszy Lingerie Costume Тa

12 03 2020
Jameserync (07:18:01) :

amature granny porn http://typossulka.rom/halva

13 03 2020
PatrickCloum (08:03:11) :
18 05 2020
poker online (23:14:28) :

Write more, thats all Ihave to saу. Literally,
it ѕeems aѕ tһough you relied on the vijdeo tto
makе уouг point. Ү᧐u clearly knoѡ what youгe
talking ɑbout, ѡhy throw away y᧐ur intelligence ᧐n jսst posting videos tօ youг sjte ԝhen you cօuld be gіving us
sߋmething enlightening to гead?

17 06 2020
biorezonans Jaworzno (11:54:04) :

Pretty portion of content. I just stumbled upon your website and in accession capital to say that I acquire actually enjoyed account your blog posts.
Anyway I will be subscribing to your augment and even I
fulfillment you get right of entry to persistently fast.

15 08 2020
losing punter (08:58:28) :

I am forever thought about this, appreciate it for putting up.

28 08 2020
read more (05:43:55) :

Valuable іnformation. Lucky me I discovered уour web site accidentally,
and I amm stunned why tһis twist of fate Ԁid not happened in advance!
I bookmarked іt.

24 09 2020 (23:13:15) :

Hi there, I wish for to subscribe for this website to get latest updates, thus
where can i do it please help out.

8 04 2021
GSBrental (06:31:52) :

Its not my first time to go to see this website, i am browsing this site dailly
and obtain fastidious facts from here daily.

11 04 2021
galeri qq (14:47:42) :

What’s Happening i am new to this, I stumbled upon this I have found It absolutely useful and it has helped
me out loads. I’m hoping to give a contribution & help other users like
its aided me. Great job.

10 05 2021
help (09:03:29) :

Earn crypto with our secret society.
We are secret community of individuals providing financial assistance each other.
We do not require anyone to make any contracts or keep any security of property for getting help.
In our community there are no givers and takers.
All likeminded individuals come together and use this great platform
and gain help. We are not a profit making organization. It is completely a team of anonymous volunteers.
More information here

23 05 2021
cây mắc ca trồng được ở đâu (00:35:10) :

It’s going to be end of mine day, except before finish I am reading this wonderful post to increase my know-how.

Laisser un commentaire

Vous pouvez utiliser ces balises html : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>