WordPress installation on FreeBSD 13.1 particularities

There’s a little specific when installing WordPress from package under FreeBSD 13 and its Apache.

Now, the Apache server coming with the distro is v. 2.4.54 and it is expecting PHP 8.0 (otherwise loading some modules is not working like msqli).
If you install WordPress from packages it will come with v.6.1 and it has dependencies on PHP 8.1, and then a little drama is starting as Apache can not loading all the needed modules and the error log is full of issues.
It becomes a nightmare, so the easiest way I have found is to do it by hand (no from packages):

1. De-install WordPress from the FreeBSD repository and PHP 8.1
2. Install PHP 8.0 from packages and add php80-zlib + php80-filter, then enable the service:
# pkg install mod_php80 php80-zlib php80-filter
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
# service php-fpm enable
# service php-fpm start
3. You need to add the following either in the httpd.conf, or create a new modules file, or example – /usr/local/etc/apache24/modules.d/001_mod-php.conf. Then add the following text:

DirectoryIndex index.php index.html

SetHandler application/x-httpd-php


SetHandler application/x-httpd-php-source


4. Touch the Apache config file, which in FreeBSD 13.1 is located at /usr/local/etc/apache24/httpd.conf
a) make sure the following like is uncommented and is there: LoadModule rewrite_module libexec/apache24/mod_rewrite.so
b) point the document root to the right directory of the WordPress, in my case it is under: /usr/local/www/wordpress. So, httpd.conf is having:
DocumentRoot “/usr/local/www/wordpress”

Options Indexes FollowSymLinks
AllowOverride None
Require all granted

5. Download the latest WordPress version (as of writing this is 6.2) and unzip it in the directory /usr/local/www/wordpress:
# wget https://wordpress.org/latest.tar.gz
# tar -xzvf latest.tar.gz
6. Restart all the services and open the IP address of the configured Apache:
# service apache24 restart