FreeBSD: Upgrade PHP4 To PHP5

How do I update PHP4 to PHP5 under FreeBSD operating systems?

You can easily specify a port to upgrade using the -o option for both portupgrade and portmaster command. To replace the installed port with a port from a different origin use the syntax as follows:

FreeBSD update php syntax

portupgrade -o {new/port} {old-port}
portmaster -o {new port dir in /usr/ports} {installed port}

WARNING! Backup your data and php / apache configuration before attempting the following commands.

Find out PHP4 version

First, find out php4 version (this is important as you need provide exact version number):
# pkg_info | grep php4
Sample output:

php4-4.4.9          PHP Scripting Language (Apache Module and CLI)

How To Upgrade PHP4 To PHP5

To replace / upgrade php4 with php5 using portmaster command, enter:
# portmaster -o /usr/ports/lang/php5 php4-4.4.9 to upgrade php5
To replace / upgrade php4 with php5 using portupgrade command, enter:
# portupgrade -o lang/php5 php4
Sample output:

** Detected a package name change: php4 (lang/php4) -> 'php5' (lang/php5)
--->  Upgrading 'php4-4.4.9' to 'php5-5.2.9' (lang/php5)
--->  Building '/usr/ports/lang/php5'
===>  Cleaning for php5-5.2.9
===>  Found saved configuration for php5-5.2.8
===>  Extracting for php5-5.2.9
=> MD5 Checksum OK for php-5.2.9.tar.bz2.
=> SHA256 Checksum OK for php-5.2.9.tar.bz2.
=> MD5 Checksum OK for suhosin-patch-5.2.9-0.9.7.patch.gz.
=> SHA256 Checksum OK for suhosin-patch-5.2.9-0.9.7.patch.gz.
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
===>  Cleaning for php5-5.2.9
--->  Cleaning out obsolete shared libraries
[Updating the pkgdb  in /var/db/pkg ... - 249 packages found (-0 +1) . done]

Once done, you need to upgrade and set new php configuration files which is located at /usr/local/etc/php.ini and /usr/local/etc/php/.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Cagri Ersen Apr 3, 2009 @ 3:40


    There is one more step to upgrade if php4-extension already installed:

    portmaster -o /usr/ports/lang/php5-extensions php4-extensions-1.0

    • 🐧 nixCraft Apr 3, 2009 @ 7:14

      Oh, yes. You need to upgrade all those extension via meta package too.

  • 0x3 Apr 3, 2009 @ 14:55

    Thanks Vivek
    What about CentOS5.2 ?


  • 🐧 nixCraft Apr 3, 2009 @ 15:06

    CentOS 5.x comes with PHP5 only. So there is no need to perform upgrade…

  • 0x3 Apr 3, 2009 @ 15:09

    ohhh sorry ….

  • Dillip Dhala Jun 27, 2009 @ 14:40

    I am using Linux 2.6.9, PHP 5.1.4 with oci8 (oracle
    On command prompt I can run the name.php file, I am also connected to oracle database, get the output. But the same output is not showing in my browser.

    In error log i found : [client] PHP Fatal error: Call to undefined function: oci_connect() in /var/www/html/dotsoft/javapr/test5.php on line 6

    Can you help me


  • HerocampHost Jul 28, 2009 @ 16:20

    its mean the oracle module not loaded, check the installation log

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum