rset(1) : Formulas

Configuring WordPress


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 {
  nclude "/usr/share/misc/mime.types"

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


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


Get the standard PHP configuration in place plus gd and mariadb

    pkg_add mariadb-server mariadb-client php-gd%7.1 php-mysqli%7.1
    ln -sf /usr/local/share/examples/php-7.1/php.ini-development /etc/php-7.1.ini
    ln -sf /usr/local/share/examples/php-7.1/mysqli.ini /etc/php-7.1/mysqli.ini
    ln -sf /etc/php-7.1.sample/gd.ini /etc/php-7.1/gd.ini
    rcctl enable php71_fpm
    rcctl start php71_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

    [ -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';

Install WordPress

Now untar the application!

    [ -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 July 06, 2020