Install PHP 8.5 on FreeBSD
| Update pkg | |
| Install the php package | |
| Verify with php -v | |
| Ports alternative |
Update pkg
FreeBSD installs binary packages with pkg. Refresh the repository catalogue first:
Update the pkg catalogue
sudo pkg update
Repository catalogue is up to date.
Wait until the update finishes before installing. A stale catalogue is the most common reason for a missing package error.
Install the php package
On FreeBSD the package name carries the version, so php85 means the PHP 8.5 build. Install it with one command and accept the dependency list when asked:
Install the PHP 8.5 package
sudo pkg install -y php85
The -y flag answers yes to the install prompt, so the command runs without stopping. Those extra packages are libraries PHP needs to run.
Verify with php -v
Check what was installed with one command:
Show the installed PHP version
php -v
PHP 8.5.0 (cli) (built: Nov 2026) (NTS) Copyright (c) The PHP Group
The first line confirms the version and the command line build. If the terminal answers that the command was not found, the install step above did not finish.
Ports alternative
The ports tree is the source based alternative: it builds the same PHP from the lang folder of the tree with options you pick yourself. It takes longer than pkg and needs the tree on disk, so start with pkg and try ports only when you need custom build options.
Next: PHP 8.5 in Docker
Article author: Arthur Isaev