Pratik Devkota
Pratik Devkota
Software engineering student interested in UNIX (GNU/Linux, *BSD, etc.), security as well as free and open-source software.

OpenBSD httpd – Dynamic Content


Continuing on with my previous article, today I am going through the process of configuring our OpenBSD httpd instance to handle dynamic content such as PHP scripts. The way httpd will accomplish this is by using the FastCGI protocol. I’ve talked about FastCGI as well as using it with Nginx in this article. So perhaps, you might want to check that out first.

Installing packages

Since we’re going to run PHP scripts, we’ll obviously need the PHP package.

doas pkg_add -z php

Installing PHP

Installing this package also includes the php-fpm script. Let’s start the script.

doas rcctl start php81_fpm

The name contains the version number, so you should keep that in mind.

Configuring httpd

Now we need to tell OpenBSD httpd to use the FastCGI socket for files ending with .php. Edit /etc/httpd.conf to look something like the following:

server "openbsd.local" {
    listen on * port 80
    directory index index.php

    location "*.php" {
        fastcgi socket "/run/php-fpm.sock"
Starting services

Now place a sample index.php file inside /var/www/htdocs/. I’ve just gone with the following:


Now time for trying out our setup.

testing the setup
Testing the setup

And it’s working!


This was a short article, and in a way that’s good. It shows how simple it is to configure OpenBSD httpd. I highly suggest you read the man page httpd.conf(5). It’s nicely written and shouldn’t take longer than 30 minutes to complete.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook