Introduction
This is an updated guide for running Apache 2.4 with Event MPM, PHP 8.3 via PHP-FPM, and MariaDB 11 on FreeBSD 14. All packages are installed via pkg, the binary package manager — no compiling from ports required.
If you are looking for the older guide using FreeBSD 10 and PHP 5.6, it is still here, but the versions covered there are all end-of-life.
Update the system
Before installing anything, update the package index and the base system:
freebsd-update fetch install
pkg update && pkg upgrade
Install Apache 2.4
pkg install apache24
Enable it to start at boot:
sysrc apache24_enable="YES"
Enable Event MPM
Edit /usr/local/etc/apache24/httpd.conf and make sure only the Event MPM module is loaded. Look for the MPM section and adjust:
#LoadModule mpm_prefork_module libexec/apache24/mod_mpm_prefork.so
#LoadModule mpm_worker_module libexec/apache24/mod_mpm_worker.so
LoadModule mpm_event_module libexec/apache24/mod_mpm_event.so
Also uncomment the proxy modules needed for PHP-FPM:
LoadModule proxy_module libexec/apache24/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so
Add a server name to avoid the startup warning:
ServerName localhost
Install PHP 8.3 with FPM
pkg install php83 php83-extensions mod_php83
Enable PHP-FPM:
sysrc php_fpm_enable="YES"
Copy the default configuration:
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
The default PHP-FPM pool listens on 127.0.0.1:9000, which is what we will use. Start it:
service php-fpm start
Install MariaDB 11
pkg install mariadb1011-server
Enable and start it:
sysrc mysql_enable="YES"
service mysql-server start
Secure the installation:
mysql_secure_installation
Set a root password and accept all other defaults.
Configure a virtual host
Create the directory /usr/local/etc/apache24/conf.d/ if it does not exist and add an include at the bottom of httpd.conf:
Include etc/apache24/conf.d/*.conf
Create your site directories:
mkdir -p /usr/local/www/mysite/{public_html,logs}
chown -R www:www /usr/local/www/mysite/
Create /usr/local/etc/apache24/conf.d/mysite.conf:
<VirtualHost *:80>
ServerName mysite.example.com
DocumentRoot "/usr/local/www/mysite/public_html"
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
<Directory "/usr/local/www/mysite/public_html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/usr/local/www/mysite/logs/error.log"
CustomLog "/usr/local/www/mysite/logs/access.log" common
</VirtualHost>
Start Apache and verify
service apache24 start
Verify the MPM in use:
httpd -V | grep MPM
Expected output:
Server MPM: event
Create a test file:
echo "<?php phpinfo();" > /usr/local/www/mysite/public_html/info.php
Open http://mysite.example.com/info.php in a browser. Look for:
Server API FPM/FastCGI
That confirms PHP-FPM is handling requests. Delete the file once verified:
rm /usr/local/www/mysite/public_html/info.php
Summary
| Component | Version |
|---|---|
| FreeBSD | 14 |
| Apache | 2.4 Event MPM |
| PHP | 8.3 FPM |
| MariaDB | 11 |