# php 5.4 > 5.6 Upgrade



## gamesquat (Feb 23, 2016)

Been trawling though some old threads here and have got part of the way through upgrading php5.4 to php5.6 on an old FreeBSD 9.3-RELEASE box but could really use some help on cleaning up the old php extensions that remain.

Started off with the following installed:


```
root@dev08:/usr/ports # pkg info | grep php

mod_php5-5.4.27,1              PHP Scripting Language
php-composer-1.0.0.a8.20140223 Dependency Manager for PHP
php5-5.4.42                    PHP Scripting Language
php5-ctype-5.4.27              The ctype shared extension for php
php5-curl-5.4.21_1             The curl shared extension for php
php5-dom-5.4.27                The dom shared extension for php
php5-extensions-1.7            A "meta-port" to install PHP extensions
php5-filter-5.4.27             The filter shared extension for php
php5-hash-5.4.27               The hash shared extension for php
php5-iconv-5.4.27              The iconv shared extension for php
php5-json-5.4.21               The json shared extension for php
php5-mysql-5.4.27              The mysql shared extension for php
php5-mysqli-5.4.27             The mysqli shared extension for php
php5-openssl-5.4.27            The openssl shared extension for php
php5-pdo-5.4.27                The pdo shared extension for php
php5-pdo_mysql-5.4.27          The pdo_mysql shared extension for php
php5-pdo_sqlite-5.4.27         The pdo_sqlite shared extension for php
php5-phar-5.4.27               The phar shared extension for php
php5-posix-5.4.27              The posix shared extension for php
php5-session-5.4.27            The session shared extension for php
php5-simplexml-5.4.27          The simplexml shared extension for php
php5-sqlite3-5.4.27            The sqlite3 shared extension for php
php5-tokenizer-5.4.27          The tokenizer shared extension for php
php5-xml-5.4.27                The xml shared extension for php
php5-xmlreader-5.4.27          The xmlreader shared extension for php
php5-xmlwriter-5.4.27          The xmlwriter shared extension for php
php5-zip-5.4.27                The zip shared extension for php
php5-zlib-5.4.31               The zlib shared extension for php
```

As php5.4 is end of life I went ahead and replaced it:


```
root@dev08:/usr/ports # portmaster -o lang/php56 php5-5.4.42
```

All went well, did a quick check and received the following info:


```
root@dev08:/usr/ports # php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/imagick.so' - Cannot open "/usr/local/lib/php/20131226/imagick.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/http.so' - Cannot open "/usr/local/lib/php/20131226/http.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/curl.so' - Cannot open "/usr/local/lib/php/20131226/curl.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/json.so' - Cannot open "/usr/local/lib/php/20131226/json.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/ctype.so' - Cannot open "/usr/local/lib/php/20131226/ctype.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/dom.so' - Cannot open "/usr/local/lib/php/20131226/dom.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/filter.so' - Cannot open "/usr/local/lib/php/20131226/filter.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/hash.so' - Cannot open "/usr/local/lib/php/20131226/hash.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/iconv.so' - Cannot open "/usr/local/lib/php/20131226/iconv.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/openssl.so' - Cannot open "/usr/local/lib/php/20131226/openssl.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/pdo.so' - Cannot open "/usr/local/lib/php/20131226/pdo.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/pdo_sqlite.so' - Cannot open "/usr/local/lib/php/20131226/pdo_sqlite.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/phar.so' - Cannot open "/usr/local/lib/php/20131226/phar.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/posix.so' - Cannot open "/usr/local/lib/php/20131226/posix.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/session.so' - Cannot open "/usr/local/lib/php/20131226/session.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/simplexml.so' - Cannot open "/usr/local/lib/php/20131226/simplexml.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/sqlite3.so' - Cannot open "/usr/local/lib/php/20131226/sqlite3.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/tokenizer.so' - Cannot open "/usr/local/lib/php/20131226/tokenizer.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/xml.so' - Cannot open "/usr/local/lib/php/20131226/xml.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/xmlreader.so' - Cannot open "/usr/local/lib/php/20131226/xmlreader.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/xmlwriter.so' - Cannot open "/usr/local/lib/php/20131226/xmlwriter.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/zip.so' - Cannot open "/usr/local/lib/php/20131226/zip.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/mysqli.so' - Cannot open "/usr/local/lib/php/20131226/mysqli.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/mysql.so' - Cannot open "/usr/local/lib/php/20131226/mysql.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/pdo_mysql.so' - Cannot open "/usr/local/lib/php/20131226/pdo_mysql.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/zlib.so' - Cannot open "/usr/local/lib/php/20131226/zlib.so" in Unknown on line 0
PHP 5.6.18 (cli) (built: Feb 23 2016 13:15:23)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
```

Lots of missing libraries. Not a problem I thought I'll just make deinstall and make reinstall... but as all the ports are end of life there's no makefile to deinstall, (this is my first time dealing with out of life ports - how do you remove them properly?).

I thought to replace them like I had php5.4 > php5.6, so I attempted that with mod_php5-5.4.27,1 and though portmaster seemed happy the new port was not installed. I also hit a wall when trying to find replacements for some of the other old extensions:


```
root@dev08:/usr/ports # make search name=php5-zip
Port:   archivers/php5-zip
Moved:
Date:   2016-02-14
Reason: PHP 5.4 is End of Life http://php.net/supported-versions.php
```

Simple I thought i'll just install the 5.6 extensions, and hope it overwrites the problematic 5.4 extensions but failed again as thats exactly what the port doesn't want to do.


```
root@dev08:/usr/ports/lang/php56-extensions # make install clean
===>   php56-extensions-1.0 depends on file: /usr/local/include/php/main/php.h - found
===>   php56-extensions-1.0 depends on file: /usr/local/lib/php/20131226/ctype.so - not found
===>  Installing for php56-ctype-5.6.18
===>   php56-ctype-5.6.18 depends on file: /usr/local/include/php/main/php.h - found
===>  Checking if php56-ctype already installed
===>   Registering installation for php56-ctype-5.6.18 as automatic
Installing php56-ctype-5.6.18...
pkg-static: php56-ctype-5.6.18 conflicts with php5-ctype-5.4.27 (installs files into the same place).  Problematic file: /usr/local/include/php/ext/ctype/config.h
*** [fake-pkg] Error code 70

Stop in /usr/ports/textproc/php56-ctype.
*** [build-depends] Error code 1

Stop in /usr/ports/lang/php56-extensions.
*** [install] Error code 1

Stop in /usr/ports/lang/php56-extensions.
```

I guess I could just `rm -r /usr/local/include/php/ext/` or at least just /ctype but I guessing that would be bad! Be real grateful if anyone could assist on how I can either overwrite, remove or preferably update the old 5.4 extensions properly and gain a clean php5.6 install.

Many Thanks.


----------



## SirDice (Feb 23, 2016)

Simplest solution is to just remove all the old PHP stuff and start a fresh install of PHP 5.6.


----------



## gamesquat (Feb 23, 2016)

My question would be what's the best way to do that, being that I can't `make deinstall` just `rm -r /usr/local/include/php/ext/`?


----------



## SirDice (Feb 23, 2016)

A `pkg delete -r php5` should to the trick. But because of the pkg-set(8) you did it may need something like `pkg delete -r php5\*`.

Note, review what is being deleted. The -r removes stuff recursively and may remove more than you expected.


----------



## gamesquat (Feb 23, 2016)

Excellent, many thanks. All worked well still have one imagick extension lurking, I'll try and find the associated port and remove that too with `pkg delete`.


```
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20131226/imagick.so'
- Cannot open "/usr/local/lib/php/20131226/imagick.so" in Unknown on line 0
```


----------



## gkontos (Feb 23, 2016)

I had to do that a few weeks ago. Instead of deleting php54 I decided to find a better upgrade path. That worked:

`portmaster -o lang/php56 php5-5.4.42`

`pkg query -e '%o ~ */php5-*' '%o'| while read origin; do new_origin=`echo ${origin} | sed -e 's/php5-/php56-/'`
echo portmaster -o ${new_origin} ${origin}; done > update.sh`

The resulting update.sh provides the portmaster steps to upgrade all extensions.


----------



## gamesquat (Feb 23, 2016)

Thanks gkontos, I saw a post that offered a similar solution but they both regrettably fail when trying to update the extensions as portmaster can't find the port its being asked to upgrade, (end of life ports 5.4).

I guess will come in handy for anybody going from 5.5 > 5.6 where the extension's port still exists in the tree:


```
[root@dev08 /usr/local]# more update.sh
portmaster -o textproc/php5-ctype
portmaster -o ftp/php5-curl
portmaster -o textproc/php5-dom
portmaster -o lang/php5-extensions
portmaster -o security/php5-filter
portmaster -o security/php5-hash
portmaster -o converters/php5-iconv
portmaster -o devel/php5-json
portmaster -o databases/php5-mysql
portmaster -o databases/php5-mysqli
portmaster -o security/php5-openssl
portmaster -o databases/php5-pdo
portmaster -o databases/php5-pdo_mysql
portmaster -o databases/php5-pdo_sqlite
portmaster -o archivers/php5-phar
portmaster -o sysutils/php5-posix
portmaster -o www/php5-session
portmaster -o textproc/php5-simplexml
portmaster -o databases/php5-sqlite3
portmaster -o devel/php5-tokenizer
portmaster -o textproc/php5-xml
portmaster -o textproc/php5-xmlreader
portmaster -o textproc/php5-xmlwriter
portmaster -o archivers/php5-zip
portmaster -o archivers/php5-zlib
[root@dev08 /usr/local]# portmaster -o textproc/php5-ctype

===>>> The first argument to -o must be a directory in /usr/ports

===>>> No valid installed port, or port directory given
===>>> Try portmaster --help
```


----------



## gkontos (Feb 23, 2016)

The script is modified from posts that I also found and did not work. My update.sh looked like this:


```
portmaster -o archivers/php56-bz2 archivers/php5-bz2
portmaster -o textproc/php56-ctype textproc/php5-ctype
portmaster -o ftp/php56-curl ftp/php5-curl
portmaster -o textproc/php56-dom textproc/php5-dom
portmaster -o lang/php56-extensions lang/php5-extensions
portmaster -o sysutils/php56-fileinfo sysutils/php5-fileinfo
portmaster -o security/php56-filter security/php5-filter
portmaster -o graphics/php56-gd graphics/php5-gd
portmaster -o security/php56-hash security/php5-hash
portmaster -o converters/php56-iconv converters/php5-iconv
portmaster -o mail/php56-imap mail/php5-imap
portmaster -o devel/php56-json devel/php5-json
portmaster -o converters/php56-mbstring converters/php5-mbstring
portmaster -o security/php56-mcrypt security/php5-mcrypt
portmaster -o databases/php56-mysql databases/php5-mysql
portmaster -o databases/php56-mysqli databases/php5-mysqli
portmaster -o security/php56-openssl security/php5-openssl
portmaster -o databases/php56-pdo databases/php5-pdo
portmaster -o databases/php56-pdo_mysql databases/php5-pdo_mysql
portmaster -o databases/php56-pdo_sqlite databases/php5-pdo_sqlite
portmaster -o archivers/php56-phar archivers/php5-phar
portmaster -o sysutils/php56-posix sysutils/php5-posix
portmaster -o www/php56-session www/php5-session
portmaster -o textproc/php56-simplexml textproc/php5-simplexml
portmaster -o net/php56-soap net/php5-soap
portmaster -o databases/php56-sqlite3 databases/php5-sqlite3
portmaster -o devel/php56-sysvsem devel/php5-sysvsem
portmaster -o devel/php56-sysvshm devel/php5-sysvshm
portmaster -o devel/php56-tokenizer devel/php5-tokenizer
portmaster -o textproc/php56-wddx textproc/php5-wddx
portmaster -o textproc/php56-xml textproc/php5-xml
portmaster -o textproc/php56-xmlreader textproc/php5-xmlreader
portmaster -o net/php56-xmlrpc net/php5-xmlrpc
portmaster -o textproc/php56-xmlwriter textproc/php5-xmlwriter
portmaster -o archivers/php56-zip archivers/php5-zip
portmaster -o archivers/php56-zlib archivers/php5-zlib
```


----------



## gamesquat (Feb 23, 2016)

Ahhh, my bad could of sworn I looked everywhere for new versions in the ports tree, stupidly was relying on `find . -name php5.*-curl` etc not `find . -name php5*-curl`. Your post made me look again, many thanks, saved me a very late night.


----------

