Set up a Docker-based development environment using Hiawatha web server, PHP-FPM, and MySQL

Set up a Docker-based development environment using Hiawatha web server, PHP-FPM, and MySQL for MyLittleForum on a subdomain. This stack meets MyLittleForum’s requirements of PHP 7.3+ and MySQL 5.7.7+ (or MariaDB 10.2.2+).

Docker Compose Setup

Create a docker-compose.yml file in your project root with these services for isolated development:

version: '3.8'
services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_DATABASE: mylittleforum
      MYSQL_USER: forumuser
      MYSQL_PASSWORD: forumpass
    ports:
      - "3307:3306"
    volumes:
      - mysql_data:/var/lib/mysql

  php:
    image: php:8.1-fpm
    volumes:
      - ./forum:/var/www/html
    depends_on:
      - mysql

  hiawatha:
    image: heri16/hiawatha
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - ./forum:/var/www/html
      - ./hiawatha/hosts.conf:/etc/hiawatha/hosts.conf
    links:
      - php:php
    environment:
      - PHP_HOST=php

Use volumes like ./forum for MyLittleForum files and ./hiawatha for config. Start with docker compose up -d.

Hiawatha Configuration

In ./hiawatha/hosts.conf, configure the VirtualHost for PHP support:

VirtualHost {
    Hostname = dev-forum.yourdomain.com
    WebsiteRoot = /var/www/html
    StartFile = index.php
    AccessLogfile = /var/www/html/access.log
    ErrorLogfile = /var/www/html/error.log
    UseFastCGI = php:9000
    PreventCSRF = enable
    PreventSQLi = enable
    PreventXSS = enable
}

This enables FastCGI to the linked PHP container on port 9000. Restart with docker compose restart hiawatha.

MyLittleForum Installation

Download MyLittleForum, extract to ./forum, set permissions: chmod -R 755 ./forum && chmod 777 ./forum/templates_c ./forum/config. Access http://localhost:8080/install/ to configure using MySQL credentials (host: mysql, db: mylittleforum). Delete /install after setup.

Deployment to Hosting

Once development finishes, zip ./forum (excluding Docker files), upload via hosting panel to subdomain root, update config/db_settings.php with production MySQL details, set permissions (templates_c: 777 initially, then 755; db_settings.php: 440), and run Hiawatha/PHP on server. Test thoroughly before going live.

Leave a Reply