php5 -> php53 how?

Just read this is /usr/ports/UPDATING:

Code:
20120516:
  AFFECTS: users of lang/php5
  AUTHOR: [email]ale@FreeBSD.org[/email]

  PHP has been updated to 5.4. Suhosin patch has been disabled until the
  new version will be released (soon). Suhosing extension will take more
  time. LINKTHR option is now enabled by default, be sure to flag it if
  you are updating using an old saved configuration. sqlite2 extension
  has been permanently removed.
  If you want to remain at PHP 5.3, a new port (lang/php53) has been
  created for such purpose.


What is the easiest way to "transfer" my PHP install to lang/php53? I still have not upgraded to 5.4 and don't plan to.
 
Just de-install old and install new from ports if you want to use it, but be careful - there are many changes done to the core, many functions deprecated - you will find changes on the PHP site - anyway, if the new will not work - you can always install the old.. ;))
 
inky: I'd guess he wants to reinstall his 5.3.13 installation from the former location lang/php5 to lang/php53 as lang/php5 is now the home for the 5.4 branch, which is the cause why it is annouced by 400.status-pkg to upgrade 5.3.13 to 5.4.3.

So if he will move from lang/php5 to lang/php53 he will stay on the 5.3.13 version, no need to be aware of any changes.

I am now doing this and best way is to
  1. go to /var/db/ports and rename php5* directories to php53* (this is to save options from php5 ports to php53)
  2. delete the php5-* packages (pkg_delete -f php5-*)
  3. go to /usr/ports/lang/php53 and do make install clean then the same for lang/php53-extensions, if you get any conflicts saying some package is already installed, just pkg_delete -f this package and do make install clean in lang/php53-extensions again[/list

    In my case step by step:
    # cd /var/db/ports
    # mv php5 php53
    # mv php5-extensions php53-extensions
    # mv php5-gd php53-gd
    # mv php5-mysql php53-mysql
    # mv php5-sqlite php53-sqlite
    # pkg_delete -f php5-*
    # cd /usr/ports/lang/php53/
    # make install clean
    # cd /usr/ports/lang/php53-extensions/
    # make install clean
    # /usr/local/etc/rc.d/apache22 restart

    Now all is working fine, and entering:
    # pkg_info | grep php
    shows all PHP packages as php53-* ones.
    # /etc/periodic/weekly/400.status-pkg
    shows no PHP package needing an upgrade.

    On one box I got an error with a PDF module having some library already installed, so I just deleted this library and ran [cmd=]make install clean[/cmd] in php53-extensions again (as I wrote already in the generic quide).

    There might be a better 'one line' solution to this but this is just what was on my mind first.
 
One note - I got some dependency errors when using portupgrade after this php5->php53 transfer. So I ran pkgdb -F which deleted some dependencies so I then reinstalled all these packages which were dependent on php5 which renewed dependencies for php53.

In my case:
# portupgrade -f eacc* pear* xcache cacti
 
That's a way to do it but IMHO it is brain dead to have to go through all this procedure just to keep lang/php53!

Most of my clients don't want php54 not because they are strange and weird but because a lot of extensions simply refuse to work. The last thing you need in a production environment is having to debug a new version.

So, I really wonder why this change was implemented without first providing an alternate and easy way to stay with the old version without having to go though all this down time.

I have emailed the port maintainer about an official solution.
 
I agree. Why not create the ports like lang/php52, lang/php53, lang/php54 right away, this avoids the stupid upgrade procedures.
 
  • Thanks
Reactions: sim
The following procedure has worked in 3 different installations so far. All of them were running php5-5.3.13

Backup your extensions configuration:

# cd /usr/local/etc/php
# cp extensions.ini extensions.ini.bak

Go to /var/db/ports and rename all php5* to php53*
Go to /var/db/pkg and get a list of your current installed php5 packages. Save this because you will need it later.

# ls | grep php > php5.packages

Delete all php5 packages.

# pkg_delete -f php5-*

Rebuild php53 and php53-extensions

# cd /usr/ports/lang/php53 && make install clean
# cd ../php53-extensions && make install clean

After this is done check for missing packages. This is were the php5.packages comes useful.

# cd /var/db/pkg && ls | grep php53 > php53.packages
# diff php5.packages php53.packages

Install the missing packages, and copy extensions.ini.bak to extensions.ini

# cd /usr/local/etc/php && cp extensions.ini.bak extensions.ini

Restart apache and tail error.log. It shouldn't report any missing extensions.
 
Rather than the manual process outlined by gkontos above, does anyone know if the method suggested for upgrading between perl versions would work?

i.e.:

env DISABLE_CONFLICTS=1 portupgrade -o lang/php53 -f php5-5.3.\*

I would of course take the precautions of backing up the extensions.ini file and saving a listing of all the installed packages.
 
thelibrarian: no this method is not working (as the versions are the same, but perl had this hint for upgrade to different version), but I didn't try the -f option for portupgrade, it might work. You can still use 'one line' in this case:

Code:
pkg_delete -f php5-5.3.\* ; cd /usr/ports/lang/php53; make install clean

with the same result :)

Also I think you don't need to backup extensions.ini as /var/db/ports/php53-extensions/option is containing all extensions installed by the php5-extensions package.
 
Bubrak: You must backup your current /usr/local/etc/php/extensions.ini because after deinstalling php5 and installing php53 the order in extensions in the new /usr/local/etc/php/extensions.ini may change, thus preventing a proper restart of apache.
 
Bubrak said:
Also I think you don't need to backup extensions.ini as /var/db/ports/php53-extensions/option is containing all extensions installed by the php5-extensions package.

There are 2 reasons why you should backup your extensions.ini
  • It is the only way to be certain that you didn't miss something during the deinstall / install procedure.
  • Extensions need to be loaded in a certain order, otherwise you might get segmentation faults.
 
serhiy, gkontos: I may be wrong but I still think that the /var/db/ports/php53-extensions/options file contains current extensions which were installed and thus these same will be installed newly and so the extensions.ini will look the same as the old one. I don't believe that i.e. in two fresh installs with same options you can get different orders in extensions.ini to get into any problems. If I think wrong explain it to me please.
 
@Bubrak,

Moving from php5 to php53 means that you have to nuke your current php installation and reinstall from scratch.

extensions.ini contains all of your current compiled extensions. Most of them been installed by the old php5-extensions port. However, there are other extensions that are not part of this meta port. Just as an example I will mention net/php53-xmlrpc which requires to be installed separately.

Backing up your extensions before and restoring after the upgrade, will make sure that an error will be generated if a module is missing when you restart your web server.

I hope this clears things.
 
Quick tips for renaming all php5 folders in /var/db/ports/. To see what the command will do, go with this command first:

for f in php* ;do echo mv $f php53${f#php5}; done

and if it's good, run it like this:

for f in php* ;do echo $f php53${f#php5}; done
 
Backing up the extensions file first is advisable I would say. They should remain the same after a reinstall, but the order can change, and that can trigger all sorts of problems (coredumps, segfaults). Yes, PHP in FreeBSD is really fun! (actually, it's a shame!)
 
marcpearsonti said:
Quick tips for renaming all php5 folders in /var/db/ports/. To see what the command will do, go with this command first:

for f in php* ;do echo mv $f php53${f#php5}; done

and if it's good, run it like this:

for f in php* ;do echo $f php53${f#php5}; done
Oops, I made a mistake in my second command, it should have read:

for f in php* ;do mv $f php53${f#php5}; done
 
Please, does someony have problem with pdflib?

My error is:
Code:
php53-extensions-1.6 depends on file: /usr/local/lib/php/20090626/pdf.so - not found
===>    Verifying install for /usr/local/lib/php/20090626/pdf.so in /usr/ports/print/pecl-pdflib
===>   Installing existing package /usr/ports/packages/All/pecl-pdflib-2.1.8_1.tbz
pkg_add: package 'php5-5.4.3' conflicts with php53-5.3.13
pkg_add: please use pkg_delete first to remove conflicting package(s) or -f to force installation
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-5.4.3.tbz' failed!
pkg_add: package 'php5-5.4.3' conflicts with php53-5.3.13
pkg_add: please use pkg_delete first to remove conflicting package(s) or -f to force installation
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-5.4.3.tbz' failed!
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-gd-5.4.3.tbz' failed!
*** Error code 1

There is a dependency problem I think.
 
When I compile, I have no package installed, it's a jailed environment. When a package is built, it is removed. Look at the dependency install process:
Code:
====>> Building lang/php53-extensions
===>   php53-extensions-1.6 depends on file: /usr/local/include/php/main/php.h - not found
===>    Verifying install for /usr/local/include/php/main/php.h in /usr/ports/lang/php53
===>   Installing existing package /usr/ports/packages/All/php53-5.3.13.tbz
===>   Returning to build of php53-extensions-1.6
===>   php53-extensions-1.6 depends on file: /usr/local/lib/php/20090626/bz2.so - not found
===>    Verifying install for /usr/local/lib/php/20090626/bz2.so in /usr/ports/archivers/php53-bz2
===>   Installing existing package /usr/ports/packages/All/php53-bz2-5.3.13.tbz
===>   Returning to build of php53-extensions-1.6
===>   php53-extensions-1.6 depends on file: /usr/local/lib/php/20090626/ctype.so - not found
===>    Verifying install for /usr/local/lib/php/20090626/ctype.so in /usr/ports/textproc/php53-ctype
===>   Installing existing package /usr/ports/packages/All/php53-ctype-5.3.13.tbz
===>   Returning to build of php53-extensions-1.6
===>   php53-extensions-1.6 depends on file: /usr/local/lib/php/20090626/curl.so - not found
===>    Verifying install for /usr/local/lib/php/20090626/curl.so in /usr/ports/ftp/php53-curl
===>   Installing existing package /usr/ports/packages/All/php53-curl-5.3.13.tbz
...
===>   Returning to build of php53-extensions-1.6
===>   php53-extensions-1.6 depends on file: /usr/local/lib/php/20090626/pdf.so - not found
===>    Verifying install for /usr/local/lib/php/20090626/pdf.so in /usr/ports/print/pecl-pdflib
===>   Installing existing package /usr/ports/packages/All/pecl-pdflib-2.1.8_1.tbz
pkg_add: package 'php5-5.4.3' conflicts with php53-5.3.13
pkg_add: please use pkg_delete first to remove conflicting package(s) or -f to force installation
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-5.4.3.tbz' failed!
pkg_add: package 'php5-5.4.3' conflicts with php53-5.3.13
pkg_add: please use pkg_delete first to remove conflicting package(s) or -f to force installation
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-5.4.3.tbz' failed!
pkg_add: autoload of dependency '/usr/ports/packages/All/php5-gd-5.4.3.tbz' failed!

All is OK except pecl-pdflib that tries to install php5-gd-5-4 (and not php53-gd).
 
I use portmaster. My /usr/local is empty because I have "NO package installed".
I try to compilte this:

Code:
databases/php53-pdo_dblib
databases/php53-pdo_mysql
databases/php53-mssql
graphics/php53-gd
lang/php53
lang/php53-extensions

The bug comes when it installs php53-extensions-1.6 => php53 => pdflib => php5-gd (bug here) => php54 (conflics because of php53-extensions installed php53).
 
Coming back to this issue, I think I've found a method that will let you upgrade the current version without first deleting it. So my case is:

Installed: php5-5.3.11 (lang/php5).
Want to upgrade to: php53-5.3.13 (lang/php53)

I've figured this hacky method, it worked fine for me in the first case.

Shell used: bash (shells/bash)

Warning: use at own risk! Make backups before you start of /var/db/pkg and /var/db/ports.

Code:
# rename dirs that contain options files from php5* to php53*
cd /var/db/ports ; for f in php* ; do mv $f php53${f#php5}; done

# replace 'php5-' for 'php53-' in all options files
grep -rl 'php5-' /var/db/ports/*/options | sort -u | xargs sed -i '' 's|php5-|php53-|g'

# replace 'php5-' for 'php53-' in all +CONTENTS and +REQUIRED_BY files (portnames, (DEP)ORIGIN's) in /var/db/pkg
grep -Erl 'php5-|lang/php5' /var/db/pkg/*/+CONTENTS /var/db/pkg/*/+REQUIRED_BY | sort -u | xargs sed -i '' 's|php5-|php53-|g;s|lang/php5|lang/php53|g'

# if you use portinstall/portupgrade, then:

pkgdb -fu

# you should be able to upgrade php53-3.11 as normal:

portupgrade -pb php53-3.11  (should give you php53-3-13).

Some general tips for upgrading PHP on FreeBSD:

  1. back up /usr/local/etc/php/extensions.ini (the order could be important) before you start
  2. after the upgrade verify with php -v that you have no coredumps or segfaults (otherwise, try restoring the backed up extensions.ini first)
  3. create php -m > /tmp/m.1 before, and php -m > /tmp/m.2 after the upgrade, and diff the two files so that you're sure you have all modules.
 
Back
Top