July 2019

My WordPress via native httpd on OpenBSD setup


I know it probably isn’t a great idea to post this site’s httpd.conf, but I do it because WordPress does not work out of the box on OpenBSD httpd. Many of the sites I used as research had errors. And, there isn’t a lot out there on this subject.
So, I am displaying this site’s httpd.conf for the benefit of other OpenBSD users trying to get WordPress working.

Here is /etc/httpd.conf after wrangling permalinks to work as “/%category%/%postname%/”


TODO: figure out if httpd.conf’s regex-like pattern matching allows for the OR operator. My tests show that the pipe symbol has no significance, commented or not.

cat /etc/httpd.conf

server "www.kapu.ca" {

        #listen on egress port 80
        listen on * tls port 443

        root "/wordpress"

        directory index index.php

       tls {
         certificate "/etc/ssl/www.kapu.ca.pem"
         key "/etc/ssl/private/www.kapu.ca.key"
       }

       location "/.well-known/acme-challenge/*" {
         root "/acme"
         request strip 2
       }

        location match "/photo/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        location match "/openbsd/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        location match "/uncategorized/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        location match "/comments/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        location match "/feed/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }


        location match "^/[0-9][0-9][0-9][0-9]/[0-9][0-9]/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        location "/*.php" {
                root "/wordpress"
                fastcgi socket "/run/php-fpm.sock"
        }

        location match "/wp-admin/.*" {
                root "/wordpress"
                fastcgi socket "/run/php-fpm.sock"
        }

        #location match "/wp-content/.*" {
        #       root "/wordpress/index.html"
        #       #fastcgi socket "/run/php-fpm.sock"
        #}

        location match "/wp/.*" {
                root "/wordpress/index.php"
                fastcgi socket "/run/php-fpm.sock"
        }

        log access wordpress-access.log

        log error wordpress-error.log
}


server "kapu.ca" {
       listen on * tls port 443
       tls {
         certificate "/etc/ssl/www.kapu.ca.pem"
         key "/etc/ssl/private/www.kapu.ca.key"
       }
       block return 301 "https://www.kapu.ca$REQUEST_URI"
}

server "www.kapu.ca" {

        listen on * port 80

        root "/wordpress"
        block return 301 "https://www.kapu.ca$REQUEST_URI"
}

server "kapu.ca" {
        listen on * port 80
        block return 301 "https://www.kapu.ca$REQUEST_URI"
}


# Include MIME types instead of the built-in ones
types {
        include "/usr/share/misc/mime.types"
}