# Multiple versions of PHP

## simon pants

Hi,

Is there any way that by using Apache vhosts that one web-site/cms could use one version of PHP with another using a different one.

My problem is that mainly I use the latest version of PHP; but I have an open-source version of a Volunteer Management System (courtesy of Oxfam) but it's only written for PHP 4.0.6. Yeah, I know its insecure, but I just want to evaluate it before I make the big decision to re-write for latest version.

SimonP

----------

## joefish

I don't know, but I would like to be able to do this too...

----------

## joefish

Actually, I think I've figured it out...

I'll post back soon once I've had a chance to test it (Might be late friday)

----------

## joefish

Well I'm still up - it's 4am and I should be in bed asleep but oh well...

OK, the easiest way to do something like this is use 2 different versions of Apache.

My situation is slightly different to yours, in that I want to run PHP4 and PHP5. To do this, here's what I have done (hopefully this well help you with your needs).

I already had Apache 2.0.52 and PHP 4.3.9 installed (the latest stable packages currently in portage). I wanted two setups, one with Apache 1.3.x and PHP 4.3.x (as this is what my web host uses), and one with PHP5 (I'll use Apache2 with this one).

First, I did

```
# emerge =apache-1.3.33
```

which will get the latest 1.3.x version of apache installed.

Secondly, I did 

```
# ACCEPT_KEYWORDS="~x86" USE="apache2" emerge mod_php
```

which will emerge PHP 5.02 (it's in ~arch). The USE="apache2" is important because otherwise PHP5 will only install it's modules for Apache 1.3.

Thirdly, I did

```
# emerge mod_php
```

Which will install PHP 4.3.9 for you. Make sure you don't have 'apache2' in your make.conf USE settings, or othewise add 'USE="-apache2" to the front of this command.

To finish off, I got a message telling me to run something like 'ebuild /var/db/pkg/dev-php/mod_php-4.3.9/mod_php-4.3.9.ebuild config'. Do that, and then don't forget to make sure that the config files have been updated to load the PHP modules on startup. (APACHE_OPTS="-D SSL -D PHP4" - in your /etc/conf.d/apache.conf, and APACHE_OPTS="-D SSL -D PHP5" - in your /etc/conf.d/apache2.conf).

Things to note:

1) The reason I did this with apache 1.3.x and apache 2.0.x, is because that way portage installs the 2 different vesions of apache in different 'slots', allowing both versions to be installed. You may be able to do this with 2 x Apache2 installs, or 2 x Apache installs, but I'm not sure.

2) I think the above also applies to PHP4 and PHP5 - Hopefully however you can get 2 different versions of PHP4 installed. Ask around as I'm not sure, but I hope this post does help you somewhat.

3) I haven't experimented with both apache servers running at once yet, since they're currently both configured to run on port 80, which means the second one wouldn't start. This isn't a problem for me, although I might figure this out later on.

I'll help you as much as I can - I'm not an expert on this, but I'll do my best.

----------

## henri

Hi Simon,

I have almost the same problem you have:

I already changed to php5 on our webserver and already modified all our running scripts to run with php5.

This included squirrelmail and a extremely customised version of osCommerce. Modifying all of the software just took me about two hours! - But now I should have a demo for a website with a php content-management-system up until the end of the week and I still can't decide myself for phpnuke, postnuke or xoops  ...  aaaahhhh  :Wink: 

Yesterday, late aat night,  I tried a beta-version of xoops that should run with php5, but it is crippled (O.K., the author wrote that it is and it would be just available for download for testing purposes, but I didn't think it would be that crippled.).

Now I have to decide between installing all of the three cms as stable versions and try to modify them all to make a decision or to also install a php4 version beneath php5 on the server or like joefish wrote to have another version of apache installed along with php4.

I think It's a decision, what is done faster.

Here are my concerns right now:

------------------------------------------------------------

1) What I did to modify my existing apps after upgrading to php5 (example osCommerce):

------------------------------------------------------------

 - tail -f /virtual-domains/domainxyz/www/log/error_log

 - Open browser and went throught the shop and the admin until the tail showed me an error, then I opened the corresponding php-page and found the line: (example: $myobj = null;) 

 - Fast search in php.net and google with keyword php5 lead to the solution (example: unset($myobj) :Wink: 

 - Now I didn't check page for page for errors, but did a ...

 - find /virtual-domains/domainxyz/www/htdocs/osc -type f -name '*.php' | xargs grep -H -e '= null;'

   This showed me any occurence of this error which I fixed then.

 - Now I went on testing the osC shop until the next error occured and so on...

If you do it this way, you're pretty fast, as I said, two hours for five different customised shops and squirrelmail! (O.K. Squirrelmail just needed one fix  :Wink:  )

The problem is, I can't really figure out how long it will take expecially for all three cms versions because for example xoops makes a extremely big use of objects. - If I just had one software to test, I woud go this way, I think.

------------------------------------------------------------

2) Install a php4 version beneath php5 just for one virtual domain

------------------------------------------------------------

How to do it? - Don't know exactly right now, but let's see:

I have some own apache mods which I use just in special directories like for example the mod_info module:

<Location /server-info>

    SetHandler server-info

    <IfModule mod_access.c>

        Order deny,allow

        Deny from all

        Allow from mydomain

    </IfModule>

</Location>

I think it should be possible to enable the php4 module kind of like this just for a special virtual host, Location or Directory.

Unfortunately I had this idea just before searching the gentoo forums and finding your thread, so I can't tell you more right now.

But there may be some difficulties like: How to avoid the php5 handler to also handle these pages? 

I really have no clue how long it will take to get that running.

------------------------------------------------------------

3) Install a second apache along with php4

------------------------------------------------------------

This will probabely be the fastest version for my needs, but I really don't know if this is a good solution on a production server, but why not?

--

Maybe you already did some more research and already found out more about how to run mod_php4 and mod_php5 together with one apache...

I'd be very glad If you could share your conclusions,

    yours Henri

----------

## simon pants

Hi All,

Sorry for lack of support/chat/feedback. Been on holiday. Am scanning your feedback and embarking on some myself.

Thanks for your replies. Very cool.

Simon

----------

## pstradomski

I managed to install both versions of mod_php (not the php itself) with portage. First, I've installed mod_php5. Then I've edited the ebuild for mod_php-4.3.10 and changed the slot to "4_${APACHEVER}" and emerged it. Now I can choose which one i want to use by editing /etc/conf.d/apache2Last edited by pstradomski on Mon Jan 31, 2005 8:53 pm; edited 1 time in total

----------

## joefish

Nice.

----------

