Configuration
ForkBB’s main configuration file is located atapp/config/main.php. This file is generated during installation from the main.dist.php template and contains all core settings for your forum.
Configuration file structure
The configuration file returns a PHP array with three main sections:- Top-level settings - Database, cookies, security, and feature settings
shared- Dependency injection container definitionsmultiple- Controller and model definitions
Base URL configuration
The base URL is the foundation for all links in your forum.app/config/main.php
Ensure the base URL matches your actual domain. Do not include a trailing slash.
Database configuration
ForkBB supports MySQL, PostgreSQL, and SQLite databases using PDO.MySQL configuration
app/config/main.php
PostgreSQL configuration
app/config/main.php
SQLite configuration
app/config/main.php
Database options
ForkBB requires the
mysqlnd driver for MySQL connections. Ensure your PHP installation includes this driver.Cookie configuration
Cookies are used for user sessions and authentication. Proper cookie configuration is essential for security.app/config/main.php
Cookie security settings
- Lax (Recommended)
- Strict
- None
SameSite=Lax provides good security while allowing normal cross-site navigation:
- Cookies sent with top-level navigations (clicking links)
- Cookies blocked on cross-site POST requests
- Good balance between security and usability
Generating secure cookie keys
Generate random, unique keys for your installation:HMAC security configuration
HMAC is used for generating secure tokens and hashes throughout ForkBB.app/config/main.php
Security headers
ForkBB includes comprehensive security headers to protect against common web vulnerabilities.app/config/main.php
Understanding security headers
Content-Security-Policy (CSP)
Content-Security-Policy (CSP)
CSP prevents XSS attacks by controlling which resources can load:
default-src 'self'- Only load resources from your domainimg-src *- Allow images from any domain (for user avatars, external images)object-src 'none'- Block plugins like Flashframe-ancestors 'none'- Prevent embedding in iframesbase-uri 'none'- Prevent base tag hijackingform-action 'self'- Forms can only submit to your domain
If you need to embed external content, adjust the CSP policy accordingly:
X-Frame-Options
X-Frame-Options
Prevents clickjacking by controlling if your site can be embedded in iframes:
DENY- Never allow embedding (recommended)SAMEORIGIN- Only allow embedding on your own domain
X-Content-Type-Options
X-Content-Type-Options
Prevents MIME type sniffing:
nosniff- Force browser to respect declared content types
Referrer-Policy
Referrer-Policy
Controls how much referrer information is sent:
strict-origin-when-cross-origin- Send full URL for same-origin, only origin for cross-origin (HTTPS → HTTP sends nothing)
Content limits
Configure maximum sizes for various content types:app/config/main.php
Size values can be specified as integers (bytes) or strings with suffixes:
'2M' (megabytes), '512K' (kilobytes).Username validation
Control username requirements and patterns:app/config/main.php
Default username rules
- Must start with a Unicode letter (
\p{L}) - Can contain letters, numbers, spaces, periods, underscores, and hyphens
- Minimum 2 characters, maximum 25 characters
Custom username patterns
Friendly URL configuration
Configure SEO-friendly URL generation:app/config/main.php
URL transformation examples
| Original | With Settings | Result |
|---|---|---|
| ”Hello World” | All enabled | hello-world |
| ”Привет мир” | translit: true | privet-mir |
| ”TEST Post” | lowercase: true | test-post |
| ”My New Topic” | WtoHyphen: true | my-new-topic |
Debug mode
Enable debugging for development:app/config/main.php
Debug levels
Maintenance mode
Temporarily disable access for maintenance:app/config/main.php
Mail configuration
Configure email sending for notifications and registration:app/config/main.php
app/config/main.php
Directory paths
ForkBB uses symbolic references for directory paths:app/config/main.php
You typically don’t need to modify directory paths unless you have a custom installation structure.
BBCode configuration
Configure BBCode parser settings:app/config/main.php
Best practices
Security
- Generate unique keys and salts for each installation
- Enable secure cookies (HTTPS)
- Keep debug mode disabled in production
- Regularly update security headers based on your needs
Performance
- Set appropriate content limits
- Configure flood intervals to prevent abuse
- Use file-based caching (enabled by default)
- Keep database connections optimized
Backups
- Always backup before configuration changes
- Store backups outside the web root
- Test configuration in development first
- Document custom settings
Validation
- Test after making configuration changes
- Check error logs for issues
- Verify security headers are working
- Test user registration and login flows
Configuration validation
After making changes, validate your configuration:Next steps
With your forum configured, learn about:- Architecture - Understand ForkBB’s structure
- User management - Managing users and groups
- Extensions - Extending ForkBB functionality