rset(1) : Formulas

Configuring WordPress

Some operations should only be run based on the output of a prior step. Use renv(1) to set a session-level environment variable indicating that the database is new.

Chroot

etc:
   [ -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/
   }

PHP

php_fpm:
   pkg_add mariadb-server mariadb-client php-mysqli%7.4 php-gd%7.4 php-zip%7.4
   ln -sf /usr/local/share/examples/php-7.4/php.ini-development /etc/php-7.4.ini
   ln -sf /usr/local/share/examples/php-7.4/mysqli.ini /etc/php-7.4/mysqli.ini
   ln -sf /usr/local/share/examples/php-7.4/zip.ini /etc/php-7.4/zip.ini
   cp /usr/local/share/examples/php-7.4/php-fpm.conf /etc/php-fpm.conf
   rcctl enable php74_fpm
   rcctl start php74_fpm

Database Initialization

mysql:
   [ -d /var/mysql ] || /usr/local/bin/mysql_install_db && $SD/renv NEW_DB="yes"
   rcctl enable mysqld
   rcctl start mysqld

init_db:
   [ "$NEW_DB" == "yes" ] && mysql <<-SQL
     CREATE DATABASE wordpress;
     CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'XXXXXXXX';
     GRANT ALL PRIVILEGES ON * . * TO 'wordpress'@'localhost';
     FLUSH PRIVILEGES;
   SQL

Unpack WordPress

wordpress:
   [ -f /var/www/wordpress/index.php ] || {
       install -d -o www -g 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

httpd.conf

# Global Options
prefork 4

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

  # XML-RPC
  location "/wp-json/*" {
      fastcgi {
          param SCRIPT_FILENAME "wordpress/index.php"
          socket "/run/php-fpm.sock"
      }
  }

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

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