# Upgrading PHP to 5.3



## antonyw (Jun 3, 2013)

Hi there!

I'm trying to upgrade the PHP version on my FreeBSD 6.2 box from 5.2.4 to 5.3. I tried doing this via portupgrade but I get stuck at the `portupgrade -ai` command. It shows the following error:


```
--->  Session started at: Mon, 03 Jun 2013 11:29:19 +0200
--->  Session ended at: Mon, 03 Jun 2013 11:29:20 +0200 (consumed 00:00:00)
/usr/local/lib/ruby/site_ruby/1.8/pkgversion.rb:41:in `initialize': : Not in due form: '<version>[_<revision>][,<epoch>]'. (ArgumentError)
        from /usr/local/sbin/portupgrade:638:in `new'
        from /usr/local/sbin/portupgrade:638:in `main'
        from /usr/local/sbin/portupgrade:613:in `each'
        from /usr/local/sbin/portupgrade:613:in `main'
        from /usr/local/sbin/portupgrade:588:in `catch'
        from /usr/local/sbin/portupgrade:588:in `main'
        from /usr/local/lib/ruby/1.8/optparse.rb:1303:in `call'
        from /usr/local/lib/ruby/1.8/optparse.rb:1303:in `parse_in_order'
         ... 7 levels...
        from /usr/local/lib/ruby/1.8/optparse.rb:785:in `initialize'
        from /usr/local/sbin/portupgrade:229:in `new'
        from /usr/local/sbin/portupgrade:229:in `main'
        from /usr/local/sbin/portupgrade:2173
```


Does anyone have an idea what causes this and how to solve? 

Many thanks!

Antony


----------



## saiman (Jun 3, 2013)

In my opinion the problem is not related to php at all. It looks like there is a problem with the portupgrade. You can try something else to upgrade the port (portmaster?) or maybe just deinstall and then reinstall the port?

Regards,
S.


----------



## antonyw (Jun 3, 2013)

I'm just trying to upgrade PHP using portupgrade. Is there perhaps another way I can upgrade PHP? Been trying all morning :l


----------



## da1 (Jun 3, 2013)

Hi,

I would use ports-mgmt/portmaster. Something along the lines of:
`pkg_info -EaIX php > php.txt`
`for i in `pkg_info -EaIX php`;do pkg_delete -f $i; done`
`portmaster `cat php.txt``

So basically, you first save the names of the packages you have installed, then you remove them and then you tell portmaster to build all of them again.

PS: make sure you check the content of php.txt beforehand.


----------



## antonyw (Jun 3, 2013)

Hi,

Thanks. I'd like to try upgrading with Portmaster, but I cannot install it...:



```
[root@xxxxxx /usr/ports/ports-mgmt/portmaster]# make install clean
"Makefile", line 27: Could not find bsd.port.options.mk
"Makefile", line 29: Malformed conditional (${PORT_OPTIONS:MBASH})
"Makefile", line 32: if-less endif
"Makefile", line 34: Malformed conditional (${PORT_OPTIONS:MZSH})
"Makefile", line 37: if-less endif
"Makefile", line 52: Malformed conditional (${PORT_OPTIONS:MBASH})
"Makefile", line 56: if-less endif
"Makefile", line 57: Malformed conditional (${PORT_OPTIONS:MZSH})
"Makefile", line 61: if-less endif
Unknown modifier 'u'
```


----------



## da1 (Jun 3, 2013)

Interesting, what about `pkg_add -r portmaster`?

PS: did you update your ports tree?


----------



## chatwizrd (Jun 3, 2013)

Your OS is outdated. Upgrade to a current supported release.


----------



## antonyw (Jun 3, 2013)

I did update my ports tree earlier today using `portsnap fetch update`. *O*utput of `pkg_add -r portmaster`:


```
Error: FTP Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/Latest/portmaster.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/Latest/portmaster.tbz' by URL
```


----------



## DutchDaemon (Jun 3, 2013)

Upgrade to a _supported_ version! According to http://www.freebsd.org/security/unsupported.html version 6.2-RELEASE has been End-of-Life (unsupported, not fixed for security issues, etc. etc.) since May 31, 2008. Which is also why you won't find any packages, and a growing number of ports won't compile on version 6. Switch to FreeBSD 8 or 9. Packages are available for versions 8 and 9 only. We prefer to direct the forum's attention and resources to _supported_ FreeBSD versions only.


----------



## antonyw (Jun 3, 2013)

Hi there,

I understand that but:

1) not so easy to upgrade a production server
2) hard to continue when my portupgrade/master utils are not even working ;-)


----------



## da1 (Jun 3, 2013)

Hi,

Upgrading is not that hard if you read the manual. it might seem scary at first but I do think it's something you should consider doing.

portupgrade/portmaster have nothing to do with upgrading the base OS.


----------



## kpa (Jun 3, 2013)

antonyw said:
			
		

> Hi there,
> 1) not so easy to upgrade a production server



In case of FreeBSD it usually is a very easy procedure. However you have pretty much painted yourself into a corner by postponing the critical updates/upgrade so much that the only solution is to do a one very large update and suffer the difficulties stemming from it.

Or, back up your data and configurations and install 9.1 from scratch.


----------



## antonyw (Jun 3, 2013)

Hi guys,

O, will give it a try.

@kpa: you are 100% correct. The server has been running fine for 5-6 years, running Nagios. It's only doing that, nothing else 

Thanks for the help!


----------



## antonyw (Jun 4, 2013)

Hi guys,

I succesfully upgraded my FreeBSD box to 9.1:


```
[root@xxxxxx /usr/ports]# uname -r
9.1-RELEASE-p3
```

Now I'm trying to update Apache (as PHP does not want to upgrade because apache is outdated).
When using portupgrade, it says the Apache port is broken. When I run `pkg_version -vIL=`, I get the following:


```
[root@xxxxx/usr/ports]# pkg_version -vIL=
apache-2.0.59                       !   Comparison failed
```

Anyone know how to fix this?


Thanks

Antony


----------



## da1 (Jun 4, 2013)

Remove Apache and install it again.


----------



## antonyw (Jun 4, 2013)

When I want to delete Apache, I get the following. Does this mean I have to uninstall PHP and pecl first? Sorry for the stupid questions, new to FreeBSD and ports management.


```
[root@xxxxxxxxx /usr/ports]# pkg_delete apache-2.0.59
pkg_delete: package 'apache-2.0.59' is required by these other packages
and may not be deinstalled:
pecl-filter-0.11.0
pecl-hash-1.5
pecl-json-1.2.1
php5-5.2.4
php5-ctype-5.2.4
php5-dom-5.2.4
php5-extensions-1.1
php5-gd-5.2.4
php5-iconv-5.2.4
php5-mbstring-5.2.4
php5-mysql-5.2.4
php5-pcre-5.2.4
php5-pdo-5.2.4
php5-posix-5.2.4_3
php5-session-5.2.4
php5-simplexml-5.2.4
php5-spl-5.2.4
php5-tokenizer-5.2.4
php5-xml-5.2.4
php5-xmlreader-5.2.4
php5-xmlwriter-5.2.4
php5-zlib-5.2.4
```


----------



## da1 (Jun 4, 2013)

You can use the -f switch when doing `pkg_delete` to force the removal of Apache without removing php and pecl first. However, maybe it would be better to remove php and pecl and Apache (heck, all ports) and then reinstall all of them.


----------



## antonyw (Jun 4, 2013)

I managed to upgrade apache to 2.2. *N*ow I'm trying to install PHP 5.3, already deleted PHP 5.2.


```
[root@xxxxxxxx /usr/ports/lang/php53]# make install clean
Shared object "libpcre.so.0" not found, required by "httpd"
Shared object "libpcre.so.0" not found, required by "httpd"
apxs:Error: Sorry, no shared object support for Apache.
apxs:Error: available under your platform. Make sure.
apxs:Error: the Apache module mod_so is compiled into.
apxs:Error: your server binary `/usr/local/sbin/httpd'..
"/usr/ports/Mk/bsd.apache.mk", line 284: warning: "/usr/local/sbin/apxs -q MPM_NAME" returned non-zero status
===>  php53-5.3.25 is marked as broken: : Error from bsd.apache.mk. apache is installed (or APACHE_PORT is defined) and port requires apache22 at least.
*** [install] Error code 1

Stop in /usr/ports/lang/php53.
```

*A*ny ideas?


----------



## da1 (Jun 4, 2013)

It seems apache is missing a library. I suggest installing sysutils/bsdadminscripts and running `pkg_libchk -o` to check all dependencies. That being said, you have to figure out if there is simply a version mismatch for pcre or if it's completely removed from your system.

Also `portmaster -y --check-depends` is a good thing to use but do read the manual for each command.


----------



## antonyw (Jun 4, 2013)

Thanks @da1.

Running the `pkg_libchk -o` command showed Apache is missing PCRE libraries. *S*o I tried to install PCRE but get the following error in the end:


```
===>  Installing for pcre-8.33
===>   Generating temporary packing list
===>  Checking if devel/pcre already installed
===>   pcre-8.33 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of devel/pcre
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** [check-already-installed] Error code 1

Stop in /usr/ports/devel/pcre.
*** [install] Error code 1

Stop in /usr/ports/devel/pcre.
```

*S*o _it_ seems like it's already installed. Double checked with `pkg_info` and indeed, it*'*s in the list:


```
pcre-8.33           Perl Compatible Regular Expressions library
```

*S*o should *I* run `make deinstall` in the /usr/ports/devel/pcre?


----------



## da1 (Jun 4, 2013)

```
You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
```

So, yes, run those two commands in the PCRE port 

LE: if, after this, Apache is still missing libraries, you might want to try recompiling Apache also (same procedure with deinstall and reinstall as above).


----------



## antonyw (Jun 4, 2013)

This worked! *T*hanks!


----------



## ShelLuser (Jun 6, 2013)

I realize I'm a bit late for the party, and also glad to read that it all worked itself out in the end. But honestly I think this was an excellent task for ports-mgmt/portmaster. Because it can cover all your bases all the time, and it doesn't have to be difficult at all.

So in your initial case, upgrading Apache, it could have been as easy as checking for a mutual package. In your case lang/php5 has a dependency on www/apache22, depending on how you configured your Port of course. In order words; all you might have needed was to tell portmaster that it should upgrade PHP, after which it would have checked for any dependencies as well: `# portmaster lang/php5`.

Or if you wanted to make sure that everything involved got rebuild you could have used: `# portmaster -tf lang/php5`. The -t tells portmaster to thoroughly recurse through your sourcecode, and -f tells it to enforce rebuilding on everything it finds.

Might be a good option for any future issues


----------

