Re: Upgrade PHP



mamrg wrote:
Hi,

First of all my apologies for the lame question, but i have this FreeBSD
server in which i have to upgrade PHP from 4 to 5.

I've read about the ports, but got a little confused.

Can you tell me please how can i make the update ?

Hmmm... this will take a little more effort than is usual when dealing
with the ports. But not a huge amount more.

First, identify all of the ports that use php -- you want anything that
is a dependency of the core lang/php4 port. You need a command something
like the following, except you will have to alter the version number to
match what you have installed:

% pkg_info -R php4-4.X.Y

Something like this:

% pkg_info -R php4-4.4.2_1
Information for php4-4.4.2_1:

Required by:
oscommerce-2.2r2
pecl-pdflib-2.0.4
php4-bz2-4.4.2_1
php4-gd-4.4.2_1
php4-mbstring-4.4.2_1
php4-mcrypt-4.4.2_1
php4-mysql-4.4.2_1
php4-pcre-4.4.2_1
php4-session-4.4.2_1
php4-zlib-4.4.2_1
phpMyAdmin-2.8.0.3

This will get you the right list of ports to deal with. Now, you need to
replace each of those ports called 'php4-something' with the equivalent
'php5-something' port. You need to do the base php port first:

% cd /usr/ports/lang/php5
% make config (Note: make sure 'Apache' is checked here)
% portupgrade -f -o lang/php5 php4-4.4.2_1

Remember to tweak that version number to match what is on your own system.
After you've done that, there should be a file /usr/local/etc/php.conf
that contains the following:

% cat /usr/local/etc/php.conf
PHP_VER=5
PHP_VERSION=5.1.4
PHP_SAPI=cli cgi mod

Now go ahead and replace all of the php4 modules with their php5
equivalents. You need to find the origin of each php4 module, and then
translate it into the php5 equivalent. eg:

% pkg_info -o php4-mysql-4.4.2_1
Information for php4-mysql-4.4.2_1:

Origin:
databases/php4-mysql
% portupgrade -o databases/php5-mysql php4-mysql-4.4.2_1

Do that for each of the php4-something modules.

Next, and somewhat optionally, reinstall all of the PECL libraries and
PHP applications you've installed. ie. anything on that list of
dependencies without the php4- prefix. This isn't strictly necessary for
anything that is pure PHP code and that involves no compiled stuff, but
it shouldn't hurt. eg:

% portupgrade -f pecl-pdflib-2.0.4
% portupgrade -f phpMyAdmin-2.8.0.3
% portupgrade -f oscommerce-2.2r2

Is it necessary to mess with Apache too ?

Yes. You should stop apache before starting on this whole exercise,
obviously. Before you fire it up again, you need to make sure that
it is loading the PHP5 module rather than the PHP4 one.

Check for lines like this in the apache config files:

LoadModule php5_module libexec/apache22/libphp5.so

(Again, mutatis mutandem depending on the version of Apache you're
running)

The Apache config files may well be automagically edited for you,
but the 'LoadModule' line could well have been put in commented out,
which you'll want to uncomment.

Then fire up Apache and test, test, test until you're sure everything
is working OK.

Cheers,

Matthew

--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature



Relevant Pages

  • RE: Very Annoying PHP Errors
    ... What I did was downgraded the php port to 5.2.0 and just re-compiled php and all of it's extensions to 5.2.0. ... I'm using FreeBSD 6.1 with Apache 2.2.4 and PHP 5.2.0 with Sushion, ipv6 support, and Apache support. ... Is there an easy way to downgrade ports? ... sometimes both but also sometimes both install without errors. ...
    (freebsd-questions)
  • Re: [6.3] Upgrading PHP5?
    ... I successfully upgraded the Ports collection with csup and then ... This is the main PHP section. ... Apache install for the first time. ...
    (freebsd-questions)
  • Re: Installing php4
    ... >>While this move to specifying all of the PHP modules as loadable ... >>that use PHP can now explicitly list all of the extensions they ... not all of the PHP consuming ports have yet been updated ... >>to depend on the appropriate PHP extensions, so installing those ...
    (freebsd-questions)
  • Re: php5 & libgd
    ... >>ive grabbed php5 and attempted to grab phpMyAdmin from ports and in ... >>Is gd located in ports? ... from my recent experience of installing php ports ... I want to install on any system that had ...
    (freebsd-questions)
  • Re: FreeBSD 6.1-STABLE + devel/php5-pcre incompatible?
    ... Jonathan Noack wrote: ... just me ) or is the php5 port complaining about a checksum ... AFFECTS: users of PHP ... The old PHP slave ports ...
    (freebsd-stable)