PHP is a commonly used programming language in development of web applications and general dynamic web pages. PHP 8.0 was a major update from version 7.4 of PHP, with some improvements and new set of features. If you are running PHP applications on a FreeBSD system that was built from this guide, read the PHP2Shell section below first, because PHP 8.0 and both FreeBSD releases it covers are now out of support.
PHP 8.0 release contains dozen of optimizations and new features which include:
- named arguments
- union types
- attributes
- constructor property promotion
- match expression
- nullsafe operator
- JIT,
- improvements in the type system, error handling, and consistency.
In this article, we shall cover all the necessary steps of installing and using PHP 8.0 on FreeBSD 13 / FreeBSD 12. For most web applications, PHP is used alongside a database system and a web server such as nginx and apache. We only include installation of Apache web server since we need it to demonstrate our PHP 8.0 installation on FreeBSD 13 / FreeBSD 12 is functional. We went back over this guide in October 2026 against the PHP2Shell advisory and the FreeBSD ports history, but did not re-run the install, because the php80 packages it uses are gone.
PHP2Shell on PHP 8.0 and FreeBSD 13 or 12: no patched package
PHP2Shell is the name for CVE-2026-109618 and CVE-2026-109619, two critical remote code execution bugs in PHP itself, fixed by the PHP project on 21 October 2026 in 8.5.12, 8.4.27, 8.3.36 and 8.2.35. PHP 8.0 reached end of life on 26 November 2023, FreeBSD removed the php80 ports on 31 December 2023, FreeBSD 12 lost support on 31 December 2023 and FreeBSD 13 on 30 April 2026. So there is no FreeBSD package or port that patches a PHP 8.0 server built from this guide.
This setup sits in the worst spot, too. The PHP security advisory rates the risk highest for Apache with mod_php, the exact stack Step 2 installs with mod_php80. The PHP team did publish a minimal source backport for 8.0, but that only helps people who build PHP themselves, and an unsupported FreeBSD base would still be underneath it.
The real fix is to rebuild on a supported FreeBSD 14 or 15 server with a current PHP branch, following our guide to installing PHP on a current FreeBSD release, and then move the application over. After installing, run pkg audit -F: it must report nothing for your php8x package, because the FreeBSD 14 package branches can lag a day or two behind a PHP release. On the old box, two commands show where you stand, run as root like the rest of this guide:
php -v
pkg audit -F
Any 8.0.x version from php -v means the server is exposed. pkg audit -F fetches FreeBSD’s vulnerability database (VuXML), but in practice VuXML only lists ports still in the tree, and the PHP2Shell entry covers the currently supported php8x ports with no php72, php73 or php80 range, so it stays quiet about PHP2Shell on php80. We checked that as a sudo user on a FreeBSD 14 lab VM in October 2026 by auditing the final 8.0.30 builds of php80 and mod_php80 next to an unpatched php83 build:
sudo pkg audit -F php80-8.0.30 mod_php80-8.0.30 php83-8.3.35
Only the php83 build is flagged. The two php80 packages do not appear at all, even though PHP2Shell affects them.
vulnxml file up-to-date
php83-8.3.35 is vulnerable:
PHP -- Multiple vulnerabilities
CVE: CVE-2026-109618
CVE: CVE-2026-109619
WWW: https://vuxml.FreeBSD.org/freebsd/d8e16d08-cd2f-11f1-8135-8447094a420f.html
1 problem(s) in 1 package(s) found.
If the server has to keep serving traffic until the move, the advisory lists measures that reduce exposure. None of them is a fix:
memory_limit = -1, set where applications cannot override it (php_admin_valuein the Apache config for mod_php, or the FPM pool), and watch RAM.session.upload_progress.enabled = 0in php.ini or the server config, never throughini_set(), then restart Apache.post_max_size = 8Mon sites without uploads, 32M where uploads are needed, withupload_max_filesizebelow it.
Check those values on a page served through Apache, since the CLI reads its own settings. The steps below are the original December 2021 install, kept as a record.
Step 1: Update FreeBSD system
We kickstart our installation with a standard system upgrade as root.
su - root
pkg update
pkg upgrade
In December 2021 the upgrade only had one package to reinstall.
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (21 candidates): 100%
Processing candidates (21 candidates): 100%
The following 1 package(s) will be affected (of 0 checked):
Installed packages to be REINSTALLED:
m4-1.4.19,1 (options changed)
Number of packages to be reinstalled: 1
253 KiB to be downloaded.
Proceed with this action? [y/N]: y
[1/1] Fetching m4-1.4.19,1.pkg: 100% 253 KiB 258.6kB/s 00:01
Checking integrity... done (0 conflicting)
[1/1] Reinstalling m4-1.4.19,1...
[1/1] Extracting m4-1.4.19,1: 100%
Alternative commands used to perform binary updates for the base system:
freebsd-update fetch
freebsd-update install
On FreeBSD 12 and 13 today those base updates no longer bring security fixes, since both releases are out of support.
Step 2: Install PHP 8.0 on FreeBSD 13 / FreeBSD 12
PHP 8.0 packages were available on FreeBSD binary distribution repositories with a number of modules when this was written. Since the ports were removed at the end of 2023, pkg no longer finds php80 or its extensions. To install PHP 8.0 on FreeBSD 13 / FreeBSD 12, we ran the command below:
pkg install php80
It pulled in four packages on FreeBSD 13.
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 4 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
libargon2: 20190702
libxml2: 2.9.12
pcre2: 10.39
php80: 8.0.13
Number of packages to be installed: 4
The process will require 40 MiB more space.
6 MiB to be downloaded.
Proceed with this action? [y/N]: y
[1/4] Fetching php80-8.0.13.pkg: 100% 4 MiB 4.3MB/s 00:01
[2/4] Fetching libxml2-2.9.12.pkg: 100% 830 KiB 849.6kB/s 00:01
[3/4] Fetching libargon2-20190702.pkg: 100% 65 KiB 67.1kB/s 00:01
[4/4] Fetching pcre2-10.39.pkg: 100% 1 MiB 1.3MB/s 00:01
Checking integrity... done (0 conflicting)
[1/4] Installing libxml2-2.9.12...
[1/4] Extracting libxml2-2.9.12: 100%
[2/4] Installing libargon2-20190702...
[2/4] Extracting libargon2-20190702: 100%
[3/4] Installing pcre2-10.39...
[3/4] Extracting pcre2-10.39: 100%
[4/4] Installing php80-8.0.13...
[4/4] Extracting php80-8.0.13: 100%
Copy the sample PHP config file:
cp -v /usr/local/etc/php.ini-production /usr/local/etc/php.ini
That php.ini is also where the interim PHP2Shell settings above go on a mod_php server.
Install PHP 8.0 extensions on FreeBSD 13 / FreeBSD 12
To install commonly used PHP extensions, run the following commands:
pkg install vim php80-xml mod_php80 php80-zip php80-mbstring php80-zlib php80-curl php80-mysqli php80-gd
Proceed with the installation by pressing y
....
The following 29 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
apache24: 2.4.52
apr: 1.7.0.1.6.1_1
ca_root_nss: 3.69_1
curl: 7.79.1
db5: 5.3.28_7
expat: 2.4.1
fontconfig: 2.13.94_1,1
freetype2: 2.11.0
gdbm: 1.21
giflib: 5.2.1
jansson: 2.14
jbigkit: 2.1_1
jpeg-turbo: 2.1.1
libgd: 2.3.1,1
libnghttp2: 1.44.0
libssh2: 1.9.0_3,3
libzip: 1.7.3
mod_php80: 8.0.13
oniguruma: 6.9.7.1
pcre: 8.45
php80-curl: 8.0.13
php80-gd: 8.0.13
php80-mbstring: 8.0.13
php80-xml: 8.0.13
php80-zip: 8.0.13
php80-zlib: 8.0.13
png: 1.6.37_1
tiff: 4.3.0
webp: 1.2.1
Number of packages to be installed: 29
The process will require 123 MiB more space.
28 MiB to be downloaded.
Proceed with this action? [y/N]: y
PHP extensions configuration files are usually located in below directory:
ls /usr/local/etc/php
Notice that mod_php80 already pulled in apache24 as a dependency, which the next step configures.
Step 3: Install Apache web server
We need Apache or any other web server to serve web pages to external users on a website. Install the package using pkg command:
pkg install apache24
Getting details about installed package:
pkg info apache24
It showed Apache 2.4.52 back then.
apache24-2.4.52
Name : apache24
Version : 2.4.52
Installed on : Wed Dec 22 23:11:15 2021 EAT
Origin : www/apache24
Architecture : FreeBSD:13:amd64
Prefix : /usr/local
Categories : www
Licenses : APACHE20
Maintainer : [email protected]
WWW : https://httpd.apache.org/
Comment : Version 2.4.x of Apache web server
....
Start and enable Apache service after the installation:
sysrc apache24_enable=yes
service apache24 start
You might want to check the status of apache24 service:
service apache24 status
A running service reports its PID.
apache24 is running as pid 546.
With Apache up, the last job is proving that it hands .php files to PHP.
Step 4: Test PHP 8.0 installation on FreeBSD 13/12
Create a PHP file which will output details about the system and PHP information.
vim /usr/local/www/apache24/data/info.php
Add these lines and save the file:
<?php
phpinfo();
?>
Configure handler for PHP pages
vim /usr/local/etc/apache24/Includes/php.conf
Paste the handler configuration, which maps .php files to mod_php.
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
Save and close the file then restart apache service:
service apache24 restart
Access the php application on your web browser at http://10.0.1.50/info.php, using your server’s IP or hostname. The screenshot below is from the original December 2021 test, so it shows PHP 8.0 as it was then:

Hurray!, you now have a working installation of PHP 8.0 on FreeBSD 13 / FreeBSD 12 system. Delete info.php once you are done, because it shows anyone your exact PHP build. If you need a database server, check out the guide in the link provided.
Thank you, great post.
regards!