One of your apps still wants the 8.4 branch and a new one was built against PHP 8.6. FreeBSD 15 lets only one PHP package live in /usr/local, and installing the second branch removes the first as soon as you confirm. We hit exactly that on a fresh box, so the side by side setup is the main job here.
We install PHP 8.5 on FreeBSD 15 from packages, run 8.4 and 8.6 beside it in two small jails, and point one nginx at all three. Then you will switch a site between branches, swap the host branch cleanly and build PHP from ports. I ran through all of it on FreeBSD 15.1 in November 2026, on a ZFS cloud instance, and every output below comes from that box.
If you only need a single PHP with the usual extensions and php-fpm on a fresh server, our guide to installing and using PHP on FreeBSD covers that path with Apache. Come back here when a second branch enters the picture.
Prerequisites
The lab host was a 4 vCPU, 16 GB instance with root on ZFS. PHP itself is light, and the two jails with a minimal base and one PHP each used 736 MB of ZFS space together, so a small VPS handles the side by side layout fine. Size for the applications, not for PHP. You need:
- FreeBSD 15.x on amd64, root on ZFS
- A user with sudo (or doas) rights
- Outbound HTTPS to pkg.FreeBSD.org and git.FreeBSD.org
- Port 80 open if you test the vhosts from another machine
On UFS the jail steps still work if you create plain directories instead of ZFS datasets. If you are still on the previous release, upgrade FreeBSD 14 to 15 with freebsd-update first, because the pkgbase commands in Step 5 need a 15.x host.
Step 1: Check which PHP branches pkg offers
FreeBSD keeps every supported PHP branch as its own package set, named after the branch, so php85 is the 8.5 interpreter and php85-intl is one of its extensions. Which point release you get depends on the repository branch your host reads. A fresh install reads quarterly, which takes only security and build fixes during a quarter, so search that one first:
pkg search -r FreeBSD-ports '^php8[0-9]-8'
Our quarterly catalogue listed five branches. The newest one was still the third release candidate, while the latest repository already carried the final release.

That gap is the first decision. The quarterly php86 package lags until the next quarterly branch is cut, so if you want the final PHP 8.6 build today you read it from latest. We keep the host on quarterly and give only the 8.6 jail the faster branch in Step 6. The table puts the package versions next to the support dates from the PHP supported versions page.
| Package | quarterly | latest | Security fixes until |
|---|---|---|---|
| php82 | 8.2.36 | 8.2.36 | 31 Dec 2026 |
| php83 | 8.3.37 | 8.3.37 | 31 Dec 2027 |
| php84 | 8.4.28 | 8.4.28 | 31 Dec 2028 |
| php85 | 8.5.13 | 8.5.13 | 31 Dec 2029 |
| php86 | 8.6.0.r3 | 8.6.0 | 31 Dec 2030 |
The 8.2 branch drops out of security support at the end of December 2026, so a new deployment should not start there. So which branch should the host run? For a server you want to leave alone for a few years, we picked 8.5, because it has final releases, every extension in the tree built for it and three years of fixes ahead.
Step 2: Install PHP 8.5 on the FreeBSD 15 host
The host gets the branch most of your sites will run, since it is the one you will patch most often. Quarterly already carries 8.5.13, so to install PHP 8.5 FreeBSD 15 needs one pkg command and no extra repository. Install the interpreter, the common extensions meta package and the few extras a typical framework asks for. Swap pdo_pgsql for pdo_mysql if your database is MariaDB or MySQL:
sudo pkg install php85 php85-extensions php85-pdo_pgsql php85-mbstring php85-intl
pkg pulled in 24 packages, including pcre2, libxml2 and the PostgreSQL client library for the PDO driver. Notice that there is no OPcache package in that list. Our first attempt included php85-opcache out of habit and pkg refused the whole transaction, which is covered under What broke. Check the result:
php -v
php -r 'var_dump(function_exists("opcache_get_status"));'
The version banner already lists Zend OPcache, and the function check returns true without any extension installed.

Since 8.5, OPcache is compiled into the PHP binary and always loaded. The PHP 8.5 migration notes also warn that an old zend_extension=opcache.so line now raises a warning, so remove it from any php.ini you carry over from an older server. The 8.4 branch still ships OPcache as php84-opcache, which matters when we fill the jails.
Enable php-fpm on the host so nginx has something to talk to. The default pool listens on 127.0.0.1 port 9000, which is what we keep for the host branch.
sudo sysrc php_fpm_enable=YES
sudo service php_fpm start
The rc script runs a config test before it starts and prints configuration file /usr/local/etc/php-fpm.conf test is successful. Pool tuning, php.ini choices and the extension list are the same as on any single PHP install, so we leave them to the main FreeBSD PHP guide linked in the intro.
Step 3: Why a second PHP package replaces the first
Why can you not just install a second branch next to the first? Every branch installs its files to the same paths, and pkg resolves the overlap by removing whatever is already there. There is no update-alternatives here, so the multiple PHP versions FreeBSD packages offer each need a root of their own. The shared paths that matter:
/usr/local/bin/phpfor the CLI/usr/local/sbin/php-fpmfor the FastCGI daemon/usr/local/etc/php.iniand thephp/extension ini directory
We asked for the 8.4 package on the PHP 8.5 host, non-interactively with ASSUME_ALWAYS_YES set, to see exactly what happens. Do not repeat this on a host you care about. Here is what pkg decided:
Checking integrity... done (1 conflicting)
- php84-8.4.28 [FreeBSD-ports] conflicts with php85-8.5.13 [installed] on /usr/local/bin/php
Checking integrity... done (0 conflicting)
The following 2 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
php84: 8.4.28 [FreeBSD-ports]
Installed packages to be REMOVED:
php85: 8.5.13 (conflicts with php84-8.4.28, which is being installed)
pkg removed php85 and installed php84. An interactive run stops at a [y/N] prompt first, but with -y or ASSUME_ALWAYS_YES nobody gets asked. The extension packages for 8.5 stay behind, and the next php -v prints a startup warning:

The leftover php85-session and friends write extension= lines into /usr/local/etc/php/, but their shared objects sit in the 8.5 API directory, so the 8.4 binary looks in 20240924 and finds nothing. The warning names session.so first, but every leftover 8.5 extension fails the same way, so code using PDO, mbstring or intl breaks along with sessions while plain pages still render. So one host holds one PHP branch. If you did run the install, put the 8.5 interpreter back. These commands follow the pkg-install and pkg-delete manual pages rather than our capture, since we went back with the full list method from Step 4. The leftover 8.5 extensions match the interpreter again once it returns:
sudo pkg delete -y php84
sudo pkg install -y php85
sudo service php_fpm restart
php -v | head -1
Everything below either swaps the host branch cleanly or puts the extra branches somewhere else.
Step 4: Switch the host to another PHP branch cleanly
If you only need to move the whole server from one branch to another, for an upgrade or a rollback, skip the jails. The rest of this guide assumes the host runs 8.5, so if you are following every step, swap and then come back as shown at the end of this step. The trick is to take the list of installed PHP packages, rename the branch prefix and install the renamed list, so every extension comes along. Save the current list first:
pkg query -e '%n ~ php85*' %n | tee /tmp/php85.list
sed 's/^php85/php84/' /tmp/php85.list > /tmp/php84.list
On our host the list had 20 package names, from php85 and php85-extensions to php85-xmlwriter, and pkg delete later removed exactly those 20. Keep /tmp/php85.list until you are sure about the move, because it is also your way back if you need to undo it. Now stop php-fpm, delete the old branch and install the new one. The 8.4 branch needs OPcache added by hand:
sudo service php_fpm stop
sudo pkg delete -y $(cat /tmp/php85.list)
sudo pkg install -y $(cat /tmp/php84.list) php84-opcache
sudo service php_fpm start
Your edited php-fpm.d/www.conf and php.ini survive the swap, because pkg leaves a config file alone once you have changed it from the sample. Ask the CLI which branch is live. We ran this swap after the nginx vhosts from Step 8 existed, so the capture also asks the app85 site; skip the curl line until you have done Step 8:
php -v | head -1
curl -s -H "Host: app85.example.lan" http://127.0.0.1/index.php
The first line names the 8.4 build, and the vhost answers with the same version through php-fpm:

The whole swap, stop to start, finished in well under a minute on our host. Going back is the same four commands with the lists reversed:
sudo service php_fpm stop
sudo pkg delete -y $(pkg query -e '%n ~ php84*' %n)
sudo pkg install -y $(cat /tmp/php85.list)
sudo service php_fpm start
That removed 21 packages, installed 20, and php -v reported 8.5.13 again. Only extensions that do not exist for the target branch need attention, and pkg names them when it fails.
Step 5: Build minimal jails for the other PHP versions
To run several PHP versions at the same time on FreeBSD, each extra branch gets its own jail with its own /usr/local. Each jail in this layout holds very little.
- A minimal FreeBSD base from packages
- One PHP branch with its extensions and php-fpm
- One loopback address on
lo1 - A read only view of the shared code tree
If jails are new to you, our FreeBSD jails with VNET networking guide explains the networking models. You do not need VNET here, because only nginx on the host talks to these jails, so the simpler shared address model is enough and keeps pf rules out of the picture.
FreeBSD 15 can install the jail base from packages, the pkgbase work described in our FreeBSD 15 new features roundup. The base repository is defined but disabled in /etc/pkg/FreeBSD.conf, so turn it on with a small override file:
sudo mkdir -p /usr/local/etc/pkg/repos
echo "FreeBSD-base: { enabled: yes }" | sudo tee /usr/local/etc/pkg/repos/FreeBSD-base.conf
sudo pkg update
The update ends with All repositories are up to date. once the base catalogue is fetched. Next, give the jails a private loopback interface and a ZFS dataset each. Addresses in 127.0.1.0/24 on lo1 never leave the host, so php-fpm in a jail cannot be reached from the network even if pf is off:
sudo sysrc cloned_interfaces+="lo1"
sudo service netif cloneup
sudo zfs create -o mountpoint=/usr/local/jails zroot/jails
sudo zfs create zroot/jails/containers
sudo zfs create zroot/jails/containers/php84
sudo zfs create zroot/jails/containers/php86
Now install the minimal jail set into each dataset. The --rootdir flag makes pkg treat the jail directory as its root, so the packages and their database land inside the jail.
sudo pkg --rootdir /usr/local/jails/containers/php84 install -y -r FreeBSD-base FreeBSD-set-minimal-jail
sudo pkg --rootdir /usr/local/jails/containers/php86 install -y -r FreeBSD-base FreeBSD-set-minimal-jail
For the php86 jail that meant 48 packages, a 25 MiB download that needs 123 MiB on disk. That beats unpacking a full base.txz, and later pkg --rootdir <jail> upgrade patches the jail base the same way it patches PHP, followed by service jail restart <jail>. That covers patch levels; moving a jail to the next minor release also means pointing the base repository at the new base_release URL first. The FreeBSD Handbook still calls base-system packages a technology preview, so keep a snapshot of the dataset before a base upgrade. Copy the host resolver config so pkg inside the jail can resolve names later:
sudo cp /etc/resolv.conf /usr/local/jails/containers/php84/etc/
sudo cp /etc/resolv.conf /usr/local/jails/containers/php86/etc/
Nothing runs in the jails yet. They are plain directory trees until the jail config in Step 7 starts them.
Step 6: Install PHP 8.4 and PHP 8.6 into the jails
PHP goes in from the host with the same --rootdir trick, so the jails never need a compiler or their own copy of the repository keys. The 8.4 jail reads the same quarterly branch as the host and needs php84-opcache listed explicitly:
sudo pkg --rootdir /usr/local/jails/containers/php84 install -y php84 php84-extensions php84-mbstring php84-opcache
That pulled 27 packages into the jail, and sudo chroot /usr/local/jails/containers/php84 php -v answered with the 8.4 banner and Zend OPcache. For the 8.6 jail we want the latest branch. Give the jail its own repository directory with the URLs switched, then point pkg at it with -R:
J=/usr/local/jails/containers/php86
sudo mkdir -p $J/usr/local/etc/pkg/repos
sed 's/quarterly/latest/' /etc/pkg/FreeBSD.conf | sudo tee $J/usr/local/etc/pkg/repos/FreeBSD.conf >/dev/null
sudo pkg -R $J/usr/local/etc/pkg/repos --rootdir $J install -y php86 php86-extensions php86-mbstring
The sed rewrites both the ports URL and the kmods URL to their latest twins, and leaves the base URL alone. That copied file still says enabled: no for FreeBSD-base, so use the -R directory for PHP packages only. Patch this jail’s base without -R, through the host config where the base repository is enabled: sudo pkg --rootdir $J upgrade -r FreeBSD-base. That command is the Handbook’s pkgbase jail upgrade with the repository named; our captures only cover the jail’s PHP upgrade check. The PHP install above pulled 25 packages, and the jail reported the final release:
PHP 8.6.0 (cli) (built: Nov 24 2026 01:06:51) (NTS)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0, Copyright © Zend by Perforce
with Zend OPcache v8.6.0, Copyright ©, by Zend by Perforce
Keep the -R flag on every later PHP package command for this jail; the base upgrade above is the one exception. Without it, pkg --rootdir falls back to the quarterly config of the host, where the 8.6 branch is still the release candidate.
Step 7: Configure and start the PHP jails
Each jail gets a small config file under /etc/jail.conf.d/. The main /etc/jail.conf only needs to include that directory:
sudo mkdir -p /etc/jail.conf.d
echo '.include "/etc/jail.conf.d/*.conf";' | sudo tee /etc/jail.conf
Create the definition for the 8.4 jail in its own file, so you can add or drop a branch later without touching the others.
sudo vi /etc/jail.conf.d/php84.conf
This is the exact file from the lab. The mount += line shares the application tree from the host into the jail read only over nullfs, so all three branches serve the same code:
php84 {
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";
exec.clean;
mount.devfs;
mount += "/usr/local/www/app $path/usr/local/www/app nullfs ro 0 0";
host.hostname = "${name}";
path = "/usr/local/jails/containers/${name}";
ip4.addr = "lo1|127.0.1.84/32";
}
Copy it for the second jail and change the name and the last octet. The mount point has to exist in each jail and the shared tree on the host, so create both before the first start:
sed 's/84/86/g' /etc/jail.conf.d/php84.conf | sudo tee /etc/jail.conf.d/php86.conf >/dev/null
sudo mkdir -p /usr/local/www/app
sudo mkdir -p /usr/local/jails/containers/php84/usr/local/www/app
sudo mkdir -p /usr/local/jails/containers/php86/usr/local/www/app
php-fpm inside each jail must listen on the address of that jail instead of 127.0.0.1. In a jail with a shared address, FreeBSD maps a 127.0.0.1 bind to the first jail address anyway, but writing it out keeps the nginx config readable when you come back to it in a year. The -R flag of sysrc edits rc.conf inside the jail from the host.
for v in 84 86; do
J=/usr/local/jails/containers/php$v
sudo sed -i '' "s/^listen = .*/listen = 127.0.1.$v:9000/" $J/usr/local/etc/php-fpm.d/www.conf
sudo sysrc -R $J php_fpm_enable=YES
done
Enable the jails at boot and start them. The jail_list fixes the start order, which helps once you have more than two:
sudo sysrc jail_enable=YES jail_list="php84 php86"
sudo service jail start php84 php86
jls
sockstat -4 -l | grep php-fpm
Both jails came up with their loopback addresses, and three php-fpm masters were listening, one per branch.

Run mount -t nullfs as well, because you want to know the code tree is visible before nginx sends traffic. It should show /usr/local/www/app mounted read only into both jails. If a jail fails to start, /var/log/jail_console_php84.log holds the rc output from inside it.
Step 8: Point nginx vhosts at each PHP version
nginx runs on the host and decides per virtual host which php-fpm gets the request. Install it and enable the service. For TLS and the rest of the nginx setup, our nginx with SSL on FreeBSD 15 guide carries on from here.
sudo pkg install -y nginx
sudo sysrc nginx_enable=YES
Add include php-sites.conf; on the line after http { in /usr/local/etc/nginx/nginx.conf, then create the include file:
sudo vi /usr/local/etc/nginx/php-sites.conf
Three server blocks share one document root. Only server_name and fastcgi_pass differ:
# One code tree, three PHP branches
server {
listen 80;
server_name app85.example.lan;
root /usr/local/www/app;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name app84.example.lan;
root /usr/local/www/app;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.1.84:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name app86.example.lan;
root /usr/local/www/app;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.1.86:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
SCRIPT_FILENAME resolves to /usr/local/www/app/index.php, and that path exists in all three places thanks to the nullfs mounts. A one line test page shows which branch answered and where it ran:
echo '<?php printf("%s via %s on %s\n", PHP_VERSION, PHP_SAPI, gethostname());' | sudo tee /usr/local/www/app/index.php
sudo service nginx start
Test each vhost from the host with a Host header, then compare with the CLI in each jail through jexec:
for v in 84 85 86; do curl -s -H "Host: app$v.example.lan" http://127.0.0.1/index.php; done
php -v | head -1; sudo jexec php84 php -v | head -1; sudo jexec php86 php -v | head -1
One FreeBSD 15 host, one code tree, three PHP versions answering at the same time.

The hostname in each line proves where the code ran, with bsd-web01 as the host and php84 and php86 as the jails. When you need command line work such as Composer or a cron job on an older branch, prefix the command with sudo jexec php84 and it runs under that branch, against the same files your vhost serves.
Step 9: Switch a site to a different PHP version
With all branches running, moving a site is a web server change, not a package change. Say you want to test the app85 site on PHP 8.6. Open its server block, change the fastcgi_pass address from 127.0.0.1:9000 to 127.0.1.86:9000, then check the config and reload.
sudo nginx -t
sudo service nginx reload
curl -s -H "Host: app85.example.lan" http://127.0.0.1/index.php
The same vhost now answers from the 8.6 jail, and nothing else on the server changed:
8.6.0 via fpm-fcgi on php86
Rolling back is the reverse edit and another reload, which is why we prefer this to swapping packages on a busy server. The cost is extension parity, because whatever the site loads must exist for the target branch. Before you switch, run pkg search php86- with the -R path of that jail and compare it with php -m on the current branch. PECL packages often trail a new PHP release by weeks.
Step 10: Build PHP from ports with non-default options
Packages are built with the default options, and for PHP that means the JIT is off. If you want it, or ZTS for a threaded extension, you build the branch from the ports tree. FreeBSD 14 removed portsnap, so the tree comes from git. Our cloud image already shipped a /usr/ports snapshot without a .git directory, frozen at release time:
ls -d /usr/ports/lang/php8*
grep -n "^PHP_DEFAULT" /usr/ports/Mk/bsd.default-versions.mk
It had no php86 port at all and still named 8.4 as the default branch.
/usr/ports/lang/php82
/usr/ports/lang/php82-extensions
/usr/ports/lang/php83
/usr/ports/lang/php83-extensions
/usr/ports/lang/php84
/usr/ports/lang/php84-extensions
/usr/ports/lang/php85
/usr/ports/lang/php85-extensions
140:PHP_DEFAULT?= 8.4
Building from that tree would mix old Makefiles with new packages. Check what you have before deleting anything. If /usr/ports is already a git checkout, a sudo git -C /usr/ports pull or a branch switch is the right fix, and an empty directory on UFS takes the clone directly. Only a non-git snapshot needs replacing, and zfs list -o name,mountpoint /usr/ports shows whether it sits on its own dataset. Ours was zroot/usr/ports, so we recreated it empty (with setuid=off, as the installer had it) and cloned the quarterly branch that matches the packages, here 2026Q4:
sudo pkg install -y git-tiny
sudo zfs destroy -r zroot/usr/ports
sudo zfs create -o mountpoint=/usr/ports -o setuid=off zroot/usr/ports
sudo git clone --depth 1 --branch 2026Q4 https://git.FreeBSD.org/ports.git /usr/ports #https://cgit.freebsd.org/ports/refs/heads
The shallow clone took 35 seconds on our host and checked out 175,710 files. Now the tree matches the quarterly branch the packages come from. The clone belongs to root, so run git there with sudo, or git refuses with “detected dubious ownership”. Check the default branch and the port versions:
grep -n "^PHP_DEFAULT" /usr/ports/Mk/bsd.default-versions.mk
for p in php82 php83 php84 php85 php86; do printf "%s " $p; make -C /usr/ports/lang/$p -V PORTVERSION; done
The quarterly tree has moved its default to 8.5, which is what ports that depend on PHP build against unless you say otherwise:
148:PHP_DEFAULT?= 8.5
php82 8.2.36
php83 8.3.37
php84 8.4.28
php85 8.5.13
php86 8.6.0.r3
If your host runs a branch other than the default, add DEFAULT_VERSIONS+=php=8.4 (or whichever branch) to /etc/make.conf, so a port that needs PHP does not drag in a second branch and hit the conflict from Step 3. Next, list the build options of the port:
make -C /usr/ports/lang/php85 showconfig
Most of the list matches what the package already does. Three options decide whether a custom build is worth it for you.
FPM=on, so php-fpm comes with every buildZTS=off, no thread safety for threaded extensionsJIT=off, the OPcache JIT compiler left out
The full output from our tree shows each option with its default.
===> The following configuration options are available for php85-8.5.13_1:
CGI=on: Build CGI version
CLI=on: Build CLI version
DEBUG=off: Build with debugging support
DTRACE=on: Build with DTrace probes
EMBED=on: Build embedded library
FPM=on: Build FPM version
IPV6=on: IPv6 protocol support
LINKTHR=on: Link thread lib (for threaded extensions)
MYSQLND=on: Build with MySQL Native Driver
NOASLR=off: Disable ASLR support
PCRE=on: Use system pcre instead of bundled one
PHPDBG=off: Interactive PHP debugger
ZTS=off: Force Zend Thread Safety (ZTS) build
JIT=off: Enable JIT support for opcache
===> Use 'make config' to modify these settings
Turning on JIT keeps the build compatible with the packaged extensions, because it does not change the PHP API. ZTS does change it, and every extension then has to be rebuilt from ports too. Install the build dependencies as binary packages first, which saves compiling Python, Perl and CMake from source:
sudo pkg install -y $(make -C /usr/ports/lang/php85 missing)
On our host that list held 34 packages. Build the port with JIT switched on. BATCH=yes skips the options dialog, and package leaves a .pkg file instead of installing straight over the running PHP:
sudo make -C /usr/ports/lang/php85 OPTIONS_SET=JIT BATCH=yes clean package
JIT adds one dependency, devel/capstone, which the build compiled from source first. The whole run took 6 minutes 56 seconds on 4 vCPUs. Install the result over the packaged binary and lock it, otherwise the next pkg upgrade replaces it with the stock build:
sudo pkg install -y /usr/ports/lang/php85/work/pkg/php85-8.5.13_1.pkg
sudo pkg lock -y php85
sudo service php_fpm restart
Now confirm three things: the binary is the local build, the packaged extensions still load without warnings, and the JIT turns on when asked:

The build date changed to the day of the build, php -m printed no warnings, and opcache_get_status() reported the JIT as enabled and on. To keep it on for the web, set opcache.jit=tracing and a non-zero opcache.jit_buffer_size in php.ini and restart php-fpm. The next pkg upgrade run told us php85-8.5.13_1 is locked and may not be modified, which is the point. The price is that you now own the security updates for this branch. When a PHP fix lands, you run sudo git -C /usr/ports pull, rebuild, unlock, install and lock again, so only do this where you will actually use the JIT.
What broke on the way
Every error below came up on the lab box while writing this, in roughly the order you are likely to meet them. If you followed the steps above in order, you should only meet the last one, and only when you copy files in by hand.
pkg: No packages available to install matching ‘php85-opcache’
Older guides, including earlier versions of this one, list phpNN-opcache in the install command. On the 8.5 branch and newer the package does not exist, and pkg aborts the whole transaction, so nothing gets installed and php is still missing afterwards:
pkg: No packages available to install matching 'php85-opcache' have been found in the repositories
sh: php: not found
Drop the package from the list. OPcache is part of the binary from 8.5 on, as Step 2 shows. Keep it for php84 and older branches, where it is still a separate package.
Warning: PHP Startup: Unable to load dynamic library ‘session.so’
This is the leftover from Step 3: a different branch was installed over the old one and the old extension packages stayed. pkg info -x '^php8' shows the mix. Remove the stray packages with sudo pkg delete -y $(pkg query -e '%n ~ php85-*' %n), then install the matching set for the branch you now run. Step 4 avoids the problem in the first place.
No php86 package for a PECL extension
Our 8.6 jail could not get Redis support: php85-pecl-redis exists, but there is no 8.6 build. The port explains why, with IGNORE_WITH_PHP=86 in databases/pecl-redis/Makefile. The extension has not been marked compatible yet, so building it from ports will not help either. Keep sites that need such an extension on a branch that has it, which is exactly what the jail layout lets you do.
fatal: destination path ‘/usr/ports’ already exists and is not an empty directory
Images that ship a ports snapshot block git clone. Moving the directory aside failed too, with mv: rename /usr/ports to /usr/ports.release: Operation not supported, because /usr/ports is a separate ZFS dataset and rename cannot move a mount point. Recreate the dataset as in Step 10. If zfs destroy reports the dataset as busy, some process still has a working directory there; fstat -f /usr/ports names it.
nginx returns “Access denied.” for a PHP file
We copied the test page in with mode 600, and php-fpm, which runs as www, could not read it. php-fpm logged Unable to open primary script: /usr/local/www/app/index.php (Permission denied). Run sudo chmod 644 on the file, or fix ownership for the whole tree. The nullfs mount passes the host permissions straight through to the jails.
Thank you, great post.
regards!