rset(1) : Formulas

Configuring WordPress

httpd (OpenBSD)

First we follow what turns out to be a fairly predictable pattern for configuring a FastCGI application

# Global Options
prefork 4

# Servers

server "default" {
    listen on "*" port 80
    log style combined
    root "/wordpress"
    directory index index.php

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

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

Then set up the chroot and restarting httpd if the server configuration changes.

execute_with=doas

httpd: wordpress/
    [ -f /var/www/etc/resolv.conf ] || {
        install -d -o www -g www /var/www/etc/
        install -m 644 -o www -g www /etc/resolv.conf /var/www/etc/
    }
    rcctl enable httpd
    ./rinstall wordpress/httpd.conf /etc/httpd.conf && rcctl restart httpd

PHP (OpenBSD)

Get the standard PHP configuration in place plus gd and mariadb

www_php:
    pkg_add mariadb-server mariadb-client php-gd%7.0 php-mysqli%7.0
    ln -sf /usr/local/share/examples/php-7.0/php.ini-development /etc/php-7.0.ini
    ln -sf /usr/local/share/examples/php-7.0/mysqli.ini /etc/php-7.0/mysqli.ini
    ln -sf /etc/php-7.0.sample/gd.ini /etc/php-7.0/gd.ini
    rcctl enable php70_fpm
    rcctl start php70_fpm

Database Initialization

Some frameworks provive extensive modules for managing the initialization of database roles and other features. This is not nessesary! Here is how one might simply initialize a new database with a new user

mysql:
    [ -d /var/mysql ] || /usr/local/bin/mysql_install_db
    rcctl enable mysqld
    rcctl start mysqld

    mysql <<-SQL
      CREATE DATABASE wordpress;
      CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'XXXXXXXX';
      GRANT ALL PRIVILEGES ON * . * TO 'wordpress'@'localhost';
      FLUSH PRIVILEGES;
    SQL

Install WordPress

Now untar the application!

wordpress:
    [ -f /var/www/wordpress/index.php ] || {
        mkdir -p /var/www/wordpress
        chown www:www /var/www/wordpress
        ./rinstall wordpress/latest.tar.gz latest.tar.gz
        tar -xzf latest.tar.gz -C /var/www
    }
    ./rinstall -o www wordpress/wp-config.php /var/www/wordpress/wp-config.php

Last updated on September 24, 2018