PHP 4 to PHP 5 Upgrade

fusionictnl

Verified User
Joined
Jun 22, 2004
Messages
1,052
Location
Netherlands
I've builded this howto from my Fedora Core 1 Machine! Apache 2 Used from DA and all went fine. (Pretty simple)



* Compile the PHP 5 lib for Apache *

- Download php to a temporary directory (http://www.php.net/downloads.php)
- cd [the temporary directory]
- tar zxvf php-5.0.x.tar.gz
- cd php-5.0.x
- /usr/local/directadmin/customapache/configure.php ( _ap2 for Apache2)
- make
- make install

* This was the install procedure * (Check if /usr/lib/apache/libphp5.so exists)

You can copy the php-dist.ini to /usr/local/lib/php.ini and edit for Register Globals on etc. (OR JUST USE THE OLD ONE IF YOU DON'T KNOW WHAT TO CHANGE ;) )

* Configure you're apache (2) *

- vi or pico /etc/httpd/conf/httpd.conf

** On my machine the httpd conf is already altered:

#
# Dynamic Shared Object (DSO) Support
#
LoadModule php4_module /usr/lib/apache/libphp4.so
LoadModule frontpage_module /usr/lib/apache/mod_frontpage.so
LoadModule perl_module /usr/lib/apache/mod_perl.so
LoadModule php5_module /usr/lib/apache/libphp5.so

** QUOTE OUT THE LoadModule php4_module:


#
# Dynamic Shared Object (DSO) Support
#
#LoadModule php4_module /usr/lib/apache/libphp4.so
LoadModule frontpage_module /usr/lib/apache/mod_frontpage.so
LoadModule perl_module /usr/lib/apache/mod_perl.so
LoadModule php5_module /usr/lib/apache/libphp5.so

Restart apache ;) And all should work GREAT! ;)

If it doesn't work! UNQUOTE the LoadModule php4_module and QUOTE the LoadModule php5_module and restart apache ;)

Problems/Successes! can be posted here ;)
 
Last edited:
Just did the whole thing on a WBEL 3.0 server with Apache 1.3.33 and everything went fine.

Only difference with Apache 2 is the changes you'll have to make in the httpd.conf.
I'll just post them in case anyone needs it :)

To make this how to work with apache 1.3.33 change the following:

Comment out:

<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
###<IfDefine HAVE_PHP4>
#AddModule mod_php4.c
###</IfDefine>


And change:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

into:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

At least, that's what I've figured :) Can someone please confirm this, as I'm no real php/apache guru, and I don't want people messing up their servers...
 
GillroY said:
Just did the whole thing on a WBEL 3.0 server with Apache 1.3.33 and everything went fine.

Only difference with Apache 2 is the changes you'll have to make in the httpd.conf.
I'll just post them in case anyone needs it :)

To make this how to work with apache 1.3.33 change the following:

Comment out:

<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
###<IfDefine HAVE_PHP4>
#AddModule mod_php4.c
###</IfDefine>


And change:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

into:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

At least, that's what I've figured :) Can someone please confirm this, as I'm no real php/apache guru, and I don't want people messing up their servers...

I Guess you mean:

And change:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

into:

<IfModule mod_php5.c>
AddType application/x-httpd-php .inc .php .php5 .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>
 
Note that Installatron is untested under PHP 5 ;)

Once more of the scripts Installatron installs work under PHP 5 we will begin testing.

Phi1.
 
In the PHP manual there's enough info about PHP 4 to PHP 5.

I quote from PHP site:

PHP 5 and the integrated Zend Engine 2 have greatly improved PHP's performance and capabilities, but great care has been taken to break as little existing code as possible. So migrating your code from PHP 4 to 5 should be very easy. Most existing PHP 4 code should be ready to run without changes, but you should still know about the few differences and take care to test your code before switching versions in production environments.

The "few differences" are: http://www.php.net/manual/en/migration5.incompatible.php

So before saying PHP 5 isn't reverse compatible :p All of my scripts and users script work fine.

There are just some minor changes in some functions, but they all still take the PHP 4 way of handling it.

As said before, I don't think much people get in troubles upgrading, as long you use you're OLD php.ini
 
Thank you this way works very well!

(step by step by me with the posts of all guys)

# cd /usr/src
# wget http://ch2.php.net/get/php-5.0.2.tar.gz/from/us2.php.net/mirror
# tar zxvf php-5.0.2.tar.gz
# cd php-5.0.2
# /usr/local/directadmin/customapache/configure.php
# make
# make install


Comment out:

<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
<IfDefine HAVE_PHP4>
#LoadModule php4_module modules/libphp4.so
</IfDefine>
...
###<IfDefine HAVE_PHP4>
#AddModule mod_php4.c
###</IfDefine>

Then change:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

into:

<IfModule mod_php5.c>
AddType application/x-httpd-php .inc .php .php5 .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

Save & exit :)wq)

Restart your apache server

# /sbin/service httpd restart
 
O.k i've did it on one of our servers for now all seems to be working lets hope it will stay this way

thanks for this littel How-to

if there will be any problems I'll let u know



Thanks,
David
Dr-Host.co.il
 
squirrelmail

After upgrading to php 5.0.3 squirrelmail stopped working.

Error message:
Warning: main(../config/config.php) [function.main]: failed to open stream: No such file or directory in /var/www/html/squirrelmail-1.4.3a/functions/global.php on line 16

Fatal error: main() [function.require]: Failed opening required '../config/config.php' (include_path='.:/usr/local/lib/php') in /var/www/html/squirrelmail-1.4.3a/functions/global.php on line 16

Anyone else have this problem or have a fix for it?

Thanks!
 
It isn't working for me. I do get it installed properly, but after that, php files don't seem to be parsed anymore.

Like: http://themis.openhost.nl/info/phpinfo.php.

I've been fizzeling with the httpd.conf of course. Commented everything out stated in this topic, commented everything with php4 in it out, added the mimetypes without <IfModule mod_php5.c>
...
</IfModule> around it, to no avail.

To go back to php4, I commented everything with php5 out, uncommented everything with php4. But, well, it stoped working.

Anyone has a solution or pointers to solve this problem?

Jochem
 
Jochem,
Your php info is showing up correctly for me so it appears you solved your problem, (or reverted back to php4?)
 
jmstacey: thanks for telling me... I checked it with Internet Explorer (my default browser is Firefox) and it, indeed, is working.

Maybe problems with sending header info, or something? Because with Firefox it's still showing the source in plain text.

Jochem
 
That's strange, since I was using firefox when I checked.

Just tried it again and its working for both FireFox and Internet Explorer on my side.

Try clearing out the cache. The browser has no jurisdiction over whether server side scripting languages such as php and perl are parsed or show source since that is.... server side.

I have noticed that Firefox likes to keep cached pages around even after multiple refreshes and on pages that should be dynamic (possibly a flaw). I find it really annoying when trying to view changes I've made to a page and nothing happens.
 
It was the problem, indeed. Thanks for the help.

I'll tell mozilla about the problem (the caching, even after multiple refreshes), because it's very iritating :p.

Jochem
 
Could anyone tell me their experiences with upgrading PHP4 to PHP5. Did any popular scripts break?
 
I heard that for example phpBB breaks with PHP5. Is this true?
 
Back
Top