Operating System BSD

How to Install ProcessWire CMS on FreeBSD 15 with Apache, MariaDB and PHP

Set up ProcessWire 3 on a FreeBSD 15 server with Apache 2.4, MariaDB and PHP 8.4, from packages to the web installer, with upgrade and troubleshooting notes.

This guide installs ProcessWire 3, an open-source PHP content management system and framework, on FreeBSD 15 with Apache 2.4, MariaDB and PHP 8.4 (a FAMP stack). At the end you have a working ProcessWire site with its admin area, and you know how to upgrade it. The commands were written for FreeBSD 15.1 and apply unchanged to FreeBSD 14.5; FreeBSD 11 has been end-of-life since 2021 and its packages are gone from the official repositories.

Requirements

  • A server running FreeBSD 15.1 (or 14.5) with root access over SSH. Run the commands below as root, or prefix them with sudo if you have installed and configured it.
  • A domain name pointing to the server; the examples use example.com.

The ProcessWire installation documentation asks for Apache (or a fully compatible server) with mod_rewrite and .htaccess support, PHP 8.x with PDO database support and either GD or ImageMagick, and MySQL 5.6 or newer or an equivalent MariaDB version.

Step 1: Update the system

Apply base system patches and bring installed packages up to date:

freebsd-update fetch install
pkg update
pkg upgrade -y

If your FreeBSD 15 system was installed from base packages (pkgbase), freebsd-update does not apply; pkg upgrade then updates the base system as well. Reboot if a new kernel was installed.

Step 2: Install Apache, MariaDB and PHP

FreeBSD packages every PHP extension separately, so list the ones ProcessWire uses explicitly:

pkg install -y apache24 mariadb118-server \
  php84 mod_php84 php84-pdo php84-pdo_mysql php84-mysqli \
  php84-gd php84-mbstring php84-ctype php84-filter php84-session \
  php84-dom php84-simplexml php84-xml php84-tokenizer php84-iconv \
  php84-fileinfo php84-curl php84-zip php84-zlib php84-opcache

MariaDB 11.8 is a long-term support series. If you prefer the older LTS branch, install mariadb1011-server instead; the rest of the guide is identical.

Create a PHP configuration from the production template:

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Enable both services at boot and start MariaDB (Apache is started after it has been configured):

sysrc apache24_enable=YES
sysrc mysql_enable=YES
service mysql-server start

Step 3: Create the database

Run the hardening script, then open a database shell:

mariadb-secure-installation
mariadb

Create a database and a user for ProcessWire, replacing the password with your own:

CREATE DATABASE processwire CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'pwuser'@'localhost' IDENTIFIED BY 'change-this-password';
GRANT ALL PRIVILEGES ON processwire.* TO 'pwuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4: Configure Apache

ProcessWire depends on mod_rewrite, which is commented out in the default FreeBSD configuration. Enable it:

sed -i '' 's|^#LoadModule rewrite_module|LoadModule rewrite_module|' /usr/local/etc/apache24/httpd.conf
grep rewrite_module /usr/local/etc/apache24/httpd.conf

The mod_php84 package loads the PHP module but does not tell Apache which files to hand to it. Create /usr/local/etc/apache24/Includes/php.conf with the handler block from the package message:

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
DirectoryIndex index.php index.html

Then create /usr/local/etc/apache24/Includes/processwire.conf for the site. AllowOverride All is required so that Apache reads the .htaccess file ProcessWire ships:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot "/usr/local/www/processwire"

    <Directory "/usr/local/www/processwire">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog "/var/log/processwire-error.log"
    CustomLog "/var/log/processwire-access.log" combined
</VirtualHost>

Step 5: Download ProcessWire

Fetch the current stable (master) archive from the project's GitHub repository and unpack it into the document root. FreeBSD's tar reads zip archives directly:

fetch -o /tmp/processwire.zip https://github.com/processwire/processwire/archive/master.zip
tar -xf /tmp/processwire.zip -C /usr/local/www
mv /usr/local/www/processwire-master /usr/local/www/processwire
chown -R www:www /usr/local/www/processwire

Apache runs as the www user on FreeBSD, and the installer needs write access to create the site directory, the configuration file and the .htaccess file. Check the configuration and start Apache:

apachectl configtest
service apache24 start

Step 6: Run the web installer

Open http://example.com/ in a browser. The installer starts automatically and guides you through these stages:

  1. Choose a site profile. The blank profile is a clean starting point; the other profiles include example templates.
  2. Review the compatibility check. Every line should pass with the packages installed above; if an extension is reported missing, install the matching php84-* package and run service apache24 restart.
  3. Enter the database settings: host localhost, database processwire, user pwuser and its password. Set your time zone and the host names the site answers to.
  4. Choose the admin login URL, the administrator user name, password and e-mail address.

When the installer finishes, let it remove the installation files it lists, then log in at the admin URL you chose.

Step 7: Tighten permissions and verify

After installation the web server only needs to write to the site's assets directory (uploads, cache, logs and sessions). Take write access away from everything else and protect the configuration file, which contains the database password:

chown -R root:wheel /usr/local/www/processwire
chown -R www:www /usr/local/www/processwire/site/assets
chown root:www /usr/local/www/processwire/site/config.php
chmod 640 /usr/local/www/processwire/site/config.php

If you want to install modules from the admin interface, also give www ownership of site/modules. Load the home page and one sub-page to confirm that URL rewriting works, and add HTTPS before you publish the site; the site has separate guides for TLS certificates.

Upgrading ProcessWire

Upgrades within version 3 are simple: back up the site files and database, then replace the wire directory with the one from the new release. On PHP 8.4 and later, also replace index.php with the new copy.

fetch -o /tmp/processwire.zip https://github.com/processwire/processwire/archive/master.zip
tar -xf /tmp/processwire.zip -C /tmp
mv /usr/local/www/processwire/wire /usr/local/www/processwire/wire.old
cp -R /tmp/processwire-master/wire /usr/local/www/processwire/wire
cp /tmp/processwire-master/index.php /usr/local/www/processwire/index.php

Reload the site a few times in the browser; ProcessWire refreshes its module cache on the first requests. Delete wire.old once everything works.

Troubleshooting

  • The home page loads but every other page returns 404: Apache is not reading .htaccess. Check that rewrite_module is loaded and that AllowOverride All applies to the directory. To test, put a few random characters at the top of .htaccess; an error 500 means the file is being read.
  • Error 500 right after installation: open .htaccess, look for the comments marked 500 NOTE and comment out the optional directives they point to, one at a time.
  • PHP source is shown instead of the page: the handler file from Step 4 is missing or Apache was not restarted.
  • Application errors: ProcessWire logs to site/assets/logs/errors.txt. For detailed output set $config->debug = true; in site/config.php temporarily, and switch it back to false on a live site.

Frequently asked questions

Can I run ProcessWire on Nginx instead of Apache?

The project documents Apache or a fully compatible server, because its routing and file protection rules live in .htaccess. Nginx setups exist in the community, but you have to translate and maintain those rules yourself, and they are not covered by the official documentation.

Should I use the master or the dev branch?

Use master for production. It is the stable branch; the dev branch carries a higher version number and newer features, and is meant for people who want to follow development.

Is mod_php the only way to run PHP with Apache on FreeBSD?

No. The mod_php84 package message itself suggests considering PHP-FPM, which runs PHP as a separate service and lets Apache use the event MPM. mod_php is used here because it needs the least configuration for a single site.

Does this work on FreeBSD 14?

Yes. The package names are the same on FreeBSD 14.5 and 15.1, since both use the same ports tree.

Share story:

Continue reading other guides on How VPS.