Operating System BSD

How to Install WordPress on OpenBSD 8.0 with httpd, PHP-FPM and MariaDB

Install WordPress on OpenBSD 8.0 with the base httpd server, PHP-FPM 8.5, MariaDB and acme-client, with the chroot setup, permalinks and upload limits handled.

This guide installs WordPress on OpenBSD 8.0, the current release (October 2026), using the httpd web server and acme-client from the base system plus PHP-FPM 8.5 and MariaDB from packages. At the end you have a WordPress site served over HTTPS with working permalinks, uploads and self-updates. OpenBSD 6.2 and 6.5, PHP 5.6 and PHP 7.3 are all long out of support; the steps below are for the current release.

Both httpd and PHP-FPM run chrooted to /var/www. Most problems with WordPress on OpenBSD come from that, so the chroot gets its own step.

Requirements

  • A server running OpenBSD 8.0 with a public IP address, and a user that can run commands through doas (or a root shell).
  • A domain name with A (and AAAA) records for example.com and www.example.com pointing to the server.
  • Ports 80 and 443 reachable. The default pf.conf does not block them.

Apply base system patches first:

doas syspatch

Step 1: Install PHP and MariaDB

doas pkg_add mariadb-server
doas pkg_add php%8.5 php-mysqli%8.5 php-curl%8.5 php-gd%8.5 php-intl%8.5 php-zip%8.5

The %8.5 suffix selects the PHP branch; OpenBSD 8.0 also carries 8.3 and 8.4. The main php package contains PHP-FPM and already has OpenSSL, mbstring, XML, zlib, exif and sodium built in. The separately packaged extensions are inactive until you link their sample .ini files into /etc/php-8.5:

for i in mysqli curl gd intl zip; do doas ln -sf ../php-8.5.sample/$i.ini /etc/php-8.5/; done

WordPress accepts uploads only up to PHP's limits. Edit /etc/php-8.5.ini and raise them to what you need, for example:

upload_max_filesize = 64M
post_max_size = 64M

Step 2: Prepare the chroot

Inside /var/www, PHP has no resolver configuration and no CA certificates, so WordPress could not reach api.wordpress.org to download updates, plugins and themes. The PHP package notes give the fix: copy the files into the chroot.

doas mkdir -p /var/www/etc/ssl
doas install -m 444 -o root -g bin /etc/resolv.conf /var/www/etc/
doas install -m 444 -o root -g bin /etc/ssl/cert.pem /etc/ssl/openssl.cnf /var/www/etc/ssl/

Repeat these commands when the originals change, for example after a system upgrade. There is no need to pin WordPress.org addresses in a hosts file, as older tutorials do; those addresses go stale.

Enable and start PHP-FPM. The packaged pool already runs as user www, chrooted, with its socket at /var/www/run/php-fpm.sock:

doas rcctl enable php85_fpm
doas rcctl start php85_fpm

Step 3: Create the database

doas mariadb-install-db
doas rcctl enable mysqld
doas rcctl start mysqld
doas mariadb-secure-installation

Open the client and create a database and an account for WordPress:

doas mariadb
CREATE DATABASE wordpress;
CREATE USER 'wordpress'@'127.0.0.1' IDENTIFIED BY 'ChangeThisPassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'127.0.0.1';
EXIT;

The account is bound to 127.0.0.1 on purpose. MariaDB's socket lives in /var/run/mysql, outside the web chroot, so PHP cannot use it; connecting over TCP to the loopback address avoids the problem. The packaged /etc/my.cnf sets bind-address=localhost, so the server is not reachable from the network. The alternative is to move the socket into the chroot, which this site's guide to Nginx, PHP-FPM and MariaDB on OpenBSD describes.

Step 4: Download WordPress

cd /tmp
ftp https://wordpress.org/latest.tar.gz
doas tar -xzf latest.tar.gz -C /var/www/htdocs
doas chown -R www:www /var/www/htdocs/wordpress

Ownership by www lets WordPress write its configuration file, store uploads and update itself from the dashboard.

Step 5: Get a certificate and configure httpd

Certificates come from Let's Encrypt through acme-client. This site has a full guide for it; the short version follows. Copy the sample configuration and add your domain at the end of /etc/acme-client.conf:

doas cp /etc/examples/acme-client.conf /etc/acme-client.conf
domain example.com {
	alternative names { www.example.com }
	domain key "/etc/ssl/private/example.com.key"
	domain full chain certificate "/etc/ssl/example.com.fullchain.pem"
	sign with letsencrypt
}

Remove the sample domain block that the file already contains. Then create /etc/httpd.conf with only the port 80 server, because httpd will not start while the certificate files are missing:

server "example.com" {
	alias "www.example.com"
	listen on * port 80
	location "/.well-known/acme-challenge/*" {
		root "/acme"
		request strip 2
	}
	location * {
		block return 302 "https://$HTTP_HOST$REQUEST_URI"
	}
}
doas httpd -n
doas rcctl enable httpd
doas rcctl start httpd
doas acme-client -v example.com

When the certificate has been issued, append the HTTPS server to /etc/httpd.conf:

server "example.com" {
	alias "www.example.com"
	listen on * tls port 443
	tls {
		certificate "/etc/ssl/example.com.fullchain.pem"
		key "/etc/ssl/private/example.com.key"
	}
	root "/htdocs/wordpress"
	directory index index.php
	connection max request body 67108864

	location "/wp-content/uploads/*.php" {
		block
	}
	location "*.php" {
		fastcgi socket "/run/php-fpm.sock"
	}
	location not found "/*" {
		request rewrite "/index.php"
	}
}

What the WordPress-specific lines do:

  • root and the socket path are written as httpd sees them inside the chroot, without the /var/www prefix.
  • connection max request body raises the 1 MB default so that uploads up to 64 MB reach PHP. Keep it in line with the PHP limits from step 1.
  • The first location refuses to execute PHP files from the uploads directory. Locations are evaluated in order and the first match wins, so it must come before the general PHP rule.
  • location "*.php" hands PHP requests to PHP-FPM; this is the block the PHP package notes give for httpd.
  • location not found sends every request that does not match an existing file to index.php. This is what makes WordPress permalinks work, since httpd has no .htaccess support.

Test and reload:

doas httpd -n && doas rcctl reload httpd

Add a daily renewal job with doas crontab -e:

~ 3 * * * acme-client example.com && rcctl reload httpd

Step 6: Run the WordPress installer

Open https://example.com/ in a browser. The installer asks for the database details:

  • Database name: wordpress
  • Username: wordpress
  • Password: the one you set in step 3
  • Database host: 127.0.0.1 (not localhost, which would make PHP look for the socket)

WordPress writes wp-config.php itself, then asks for the site title and the administrator account. Afterwards, go to Settings, Permalinks, pick a structure other than "Plain" and open a post to confirm that the rewrite rule works. Tools, Site Health reports any missing PHP module and whether WordPress can reach WordPress.org.

Maintenance

  • Check the services with doas rcctl check httpd php85_fpm mysqld. httpd logs to /var/www/logs/access.log and error.log.
  • WordPress core, plugins and themes update from the dashboard. The operating system side is doas syspatch for the base system and doas pkg_add -u for packages; restart php85_fpm after a PHP update and run doas mariadb-upgrade after a MariaDB update.
  • Back up the database with doas mariadb-dump wordpress > wordpress.sql together with /var/www/htdocs/wordpress/wp-content and wp-config.php.

Frequently asked questions

Why does WordPress not send e-mail?

PHP's mail() starts an external sendmail program through a shell, and neither exists inside the chroot. The PHP package notes recommend sending over SMTP instead; in WordPress that means an SMTP plugin configured with your mail provider's server.

Why do I see "Error establishing a database connection"?

Usually the database host is set to localhost. PHP then looks for a socket file that is not visible inside /var/www. Set DB_HOST in wp-config.php to 127.0.0.1 and make sure the database account was created for 'wordpress'@'127.0.0.1'.

Uploads fail with "413" or "exceeds the maximum upload size". What should I change?

Three limits apply and the smallest one wins: connection max request body in /etc/httpd.conf, and post_max_size and upload_max_filesize in /etc/php-8.5.ini. Reload httpd and restart php85_fpm after changing them.

Can I use Nginx or Apache instead of httpd?

Yes, both are available as packages and WordPress runs on either. httpd is part of the base system, is maintained with it and needs only the short configuration shown here, which is why it is the usual choice on OpenBSD.

Share story:

Continue reading other guides on How VPS.