opt-php · PHP 5.6–8.6 for FreeBSD
A signed pkg repository with every PHP branch from 5.6 to 8.6, built from the
deb.sury.org patch series and installed side by side under
/opt/php/X.Y.
- FreeBSD:15:amd64/quarterly, FreeBSD:15:amd64/latest
- 652 packages
- updated 2026-11-21 06:40 UTC
Provided as is, without warranty of any kind; builds and updates are best effort. See the disclaimer.
Ondřej Surý maintains, at deb.sury.org, PHP packages for Debian and Ubuntu that keep receiving security backports long after upstream end of life, plus the fixes needed to build old PHP against current OpenSSL 3, ICU and libxml2. opt-php takes those source packages and builds them for FreeBSD, so that legacy applications can run on a supported FreeBSD release next to current PHP.
- Every version can be installed at the same time, each under its own prefix with its own
configuration and PHP-FPM service. They do not conflict with each other nor with the official
php8xFreeBSD packages. - Only PHP is in this repository. Libraries (ICU, libxml2, curl, ImageMagick…) come from the
official FreeBSD repository, and the packages are built against exactly the same ports tree as the
official
latestpackages. - Updates follow deb.sury.org: new sury releases are picked up, built and published automatically, usually within the hour.
Quick start
1. Fetch the repository signing key and check its fingerprint:
fetch -o /usr/local/etc/ssl/certs/opt-php.pub https://pkg.indeax.com/opt-php/opt-php.pub
sha256 /usr/local/etc/ssl/certs/opt-php.pub
# SHA256 = 1f307fb7616ea91db4be2dc6ee2108f9ba04a58f348262ef39a4df1d5de4bd93
2. Add the repository:
cat > /usr/local/etc/pkg/repos/opt-php.conf <<'EOF'
opt-php: {
url: "https://pkg.indeax.com/opt-php/${ABI}/quarterly",
signature_type: "pubkey",
pubkey: "/usr/local/etc/ssl/certs/opt-php.pub",
enabled: yes
}
EOF
pkg update
3. Install a PHP version with the extensions you need, and start PHP-FPM:
pkg install opt-php84 opt-php84-opcache opt-php84-mysqli opt-php84-pdo_mysql \
opt-php84-mbstring opt-php84-intl opt-php84-gd opt-php84-curl opt-php84-zip
sysrc opt_php84_fpm_enable=YES
service opt_php84_fpm start
php8.4 -v
pkg.FreeBSD.org, the URL ends with the package branch: use the
same branch as your FreeBSD-ports repository, so that opt-php is linked against
the same library versions you get from FreeBSD. That is quarterly on a default FreeBSD install
(as above); if you switched to latest, use /opt-php/${ABI}/latest instead. You can
check yours with pkg -vv | grep url.Versions
FreeBSD:15:amd64 · quarterly
URL https://pkg.indeax.com/opt-php/${ABI}/quarterly · 326 packages · full list
| Branch | Package | Version (sury revision) | Extensions | FPM service |
|---|---|---|---|---|
| 5.6 | opt-php56 | 5.6.40 (110) | 25 | opt_php56_fpm |
| 7.0 | opt-php70 | 7.0.33 (98) | 24 | opt_php70_fpm |
| 7.1 | opt-php71 | 7.1.33 (86) | 24 | opt_php71_fpm |
| 7.2 | opt-php72 | 7.2.34 (71) | 25 | opt_php72_fpm |
| 7.3 | opt-php73 | 7.3.33 (42) | 25 | opt_php73_fpm |
| 7.4 | opt-php74 | 7.4.33 (38) | 25 | opt_php74_fpm |
| 8.0 | opt-php80 | 8.0.30 (32) | 25 | opt_php80_fpm |
| 8.1 | opt-php81 | 8.1.34 (15) | 25 | opt_php81_fpm |
| 8.2 | opt-php82 | 8.2.36 (3) | 25 | opt_php82_fpm |
| 8.3 | opt-php83 | 8.3.37 (3) | 25 | opt_php83_fpm |
| 8.4 | opt-php84 | 8.4.28 (3) | 25 | opt_php84_fpm |
| 8.5 | opt-php85 | 8.5.13 (3) | 24 | opt_php85_fpm |
| 8.6 | opt-php86 | 8.6.0 (3) | 16 | opt_php86_fpm |
FreeBSD:15:amd64 · latest
URL https://pkg.indeax.com/opt-php/${ABI}/latest · 326 packages · full list
| Branch | Package | Version (sury revision) | Extensions | FPM service |
|---|---|---|---|---|
| 5.6 | opt-php56 | 5.6.40 (110) | 25 | opt_php56_fpm |
| 7.0 | opt-php70 | 7.0.33 (98) | 24 | opt_php70_fpm |
| 7.1 | opt-php71 | 7.1.33 (86) | 24 | opt_php71_fpm |
| 7.2 | opt-php72 | 7.2.34 (71) | 25 | opt_php72_fpm |
| 7.3 | opt-php73 | 7.3.33 (42) | 25 | opt_php73_fpm |
| 7.4 | opt-php74 | 7.4.33 (38) | 25 | opt_php74_fpm |
| 8.0 | opt-php80 | 8.0.30 (32) | 25 | opt_php80_fpm |
| 8.1 | opt-php81 | 8.1.34 (15) | 25 | opt_php81_fpm |
| 8.2 | opt-php82 | 8.2.36 (3) | 25 | opt_php82_fpm |
| 8.3 | opt-php83 | 8.3.37 (3) | 25 | opt_php83_fpm |
| 8.4 | opt-php84 | 8.4.28 (3) | 25 | opt_php84_fpm |
| 8.5 | opt-php85 | 8.5.13 (3) | 24 | opt_php85_fpm |
| 8.6 | opt-php86 | 8.6.0 (3) | 16 | opt_php86_fpm |
The fourth field of the package version is the deb.sury.org revision it was built from
(for example 8.4.28.2 is PHP 8.4.28, sury revision 2). Both branches are built from the same
deb.sury.org sources; they only differ in the FreeBSD libraries they are linked against.
Packages
Core: opt-phpXY
CLI and PHP-FPM, with these extensions built in: bcmath, bz2, calendar, ctype, dom, exif, fileinfo, filter, ftp, hash, iconv, json, libxml, mysqlnd, openssl, pcre, pdo, phar, posix, session, shmop, simplexml, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter and zlib. PHP 8.5 and later also include opcache, which is no longer optional upstream.
Extensions: opt-phpXY-<name>
| Extension | Notes |
|---|---|
opcache | Up to 8.4 (built into the core since 8.5). |
mysqli, pdo_mysql | On mysqlnd; default socket /tmp/mysql.sock. |
mysql | The old mysql_* API, PHP 5.6 only. |
mbstring, intl, gd, curl, zip, soap, xsl | The usual set for WordPress, PrestaShop and Magento (Magento 2 requires xsl). |
sodium | PHP 7.2 and later. |
gettext, gmp, sqlite3, pdo_sqlite | |
pcntl, readline | Enabled for the CLI only, never in PHP-FPM. |
mcrypt | Bundled up to 7.1, PECL from 7.2 (needed by Magento 1 and some PrestaShop 1.6 shops). |
imap | Bundled up to 8.3, PECL from 8.4. |
igbinary, redis, memcached | redis and memcached are built with igbinary support; redis also with lzf, lz4 and zstd (5.6: lzf only). |
apcu, imagick | imagick uses the official ImageMagick7-nox11 package. |
xdebug | For development: it is enabled as soon as it is installed. |
PECL extensions come from the deb.sury.org source package for each branch, so every PHP version gets the extension release that sury ships for it (for example phpredis 4.3 for 5.6 and 6.3 for 8.x).
Using it
Layout
/opt/php/8.4/bin/php CLI (also /usr/local/bin/php8.4, phpize8.4, php-config8.4)
/opt/php/8.4/sbin/php-fpm PHP-FPM
/opt/php/8.4/etc/cli/php.ini php.ini for the CLI
/opt/php/8.4/etc/cli/conf.d/*.ini extensions loaded by the CLI
/opt/php/8.4/etc/fpm/php.ini php.ini for PHP-FPM
/opt/php/8.4/etc/fpm/conf.d/*.ini extensions loaded by PHP-FPM
/opt/php/8.4/etc/fpm/php-fpm.conf global PHP-FPM settings
/opt/php/8.4/etc/fpm/pool.d/*.conf pools (www.conf by default)
/usr/local/etc/rc.d/opt_php84_fpm rc service
/var/run/php/php8.4-fpm.sock default pool socket (owner www, mode 0660)
/var/log/php/php8.4-fpm.log PHP-FPM log
/var/db/php/8.4/sessions session.save_path
Configuration files are installed as samples (@sample): your changes are kept on
upgrades. To disable an extension for one SAPI, comment out its line in
etc/<sapi>/conf.d/NN-<name>.ini (deleting the file is undone by the next upgrade).
Web server
Point each site at the socket of the version it needs, for example with nginx:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Several versions can run at once: enable opt_php56_fpm, opt_php74_fpm,
opt_php84_fpm… and give each site the matching socket. The rc script also supports
reload, configtest and logrotate.
Building other PECL extensions
Each version ships its phpize and php-config
(phpize8.4, php-config8.4); use
./configure --with-php-config=/opt/php/8.4/bin/php-config. PHP 5.6–7.3 also need
devel/libtool and devel/autoconf installed.
How it is built
- Sources come from php.net and pecl.php.net (byte-identical to the deb.sury.org
origtarballs). The deb.sury.org patch series of each source package is applied in order, except Debian-specific paths and packaging, which are reverted or skipped for FreeBSD. The patches applied to each port are kept in the source repository, so building from it never downloads anything from deb.sury.org. - The DNS telemetry that deb.sury.org added in 2026 (a query to
telemetry.sury.orgwhen PHP-FPM starts) is removed. New patches are reviewed automatically: any patch adding network calls or telemetry holds back that release until it is checked by hand. - Packages are built with poudriere on FreeBSD 15 amd64, once for each package branch, against
the ports tree commit used for the official
quarterlyandlatestpackages. Each branch is only published when every package of its set builds and passes the poudriere checks. - The build checks deb.sury.org every 30 minutes and also rebuilds every night, so extensions follow ABI changes of the official libraries.
Disclaimer
This repository is a best-effort service, without any warranty. The packages are provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or operators of opt-php be liable for any claim, damages or other liability arising from the use of these packages or of this repository.
- There is no service level: builds, security updates and the repository itself may be delayed, interrupted or discontinued at any time, without notice.
- Security fixes for end-of-life branches depend entirely on the backports published by deb.sury.org, which are themselves best effort; a vulnerability may stay unfixed.
- Packages are built and tested automatically, not audited. Test them before using them in production, and keep your own backups and rollback plan.
Licenses and credits
PHP is distributed under the PHP License 3.01 and the Zend Engine under the Zend Engine License 2.00 (up to 8.5); since 8.6 both are under a single BSD-3-Clause license.
This product includes PHP software, freely available from
http://www.php.net/software/.
This product includes the Zend Engine, freely available at
http://www.zend.com/.
The deb.sury.org packaging and patches are under the Expat (MIT) license. PECL extensions keep their own
licenses (PHP 3.01; igbinary BSD-3-Clause; xdebug, the Xdebug License). Every package installs its
licenses under /opt/php/X.Y/share/licenses/, and a NOTICE plus the Debian
copyright file under /opt/php/X.Y/share/doc/<package>/.