This is the procedure for upgrading to a minor or major version of the PHP scripting language on a FreeBSD server.

PHP release announcements.

New releases of minor and major versions of PHP are announced on the PHP website. You might also get notified about this from other sources, such as the WordPress dashboard. You will want to make sure, that you upgrade to a PHP version, that is supported by your applications.

Determine the installed version of PHP on your FreeBSD server.

You can determine the installed version of PHP by using the PHP command line interface php. If this version is not the version, that is recommended and supported by your applications, then you will want to upgrade.

# php -v

Remove old version of PHP.

You should remove the old, or the older, versions of PHP and PHP extensions for security reasons. You can have the FreeBSD package manager make a list of all PHP packages, that are currently installed, and then use the list to delete them.

List installed PHP and PHP extensions packages. In this example PHP 7.3 and Apache module extension is installed.

# pkg info | grep php
mod_php73-7.3.27               PHP Scripting Language
php73-7.3.27                   PHP Scripting Language
php73-ctype-7.3.27             The ctype shared extension for php

If the list looks fine, then convert it to arguments for the package manager, so you will not have to construct the command manually.

# pkg info | grep php | awk '{printf $1." "}'
mod_php73-7.3.27 php73-7.3.27 php73-ctype-7.3.27 ...

If the arguments look fine, then delete them with the package manager.

# pkg delete `pkg info | grep php | awk '{printf $1." "}'`

Install the version of PHP, that you want to upgrade to.