Overview
ForkBB provides a command-line interface (cli.php) for performing administrative tasks such as installing the forum software and managing the email queue. All commands are executed through PHP’s CLI SAPI.
Basic Usage
All CLI commands follow this basic syntax:Available Commands
install
Installs ForkBB from the command line with all necessary configuration parameters.This command is only available when
config/install.php exists and config/main.php does not yet exist.Syntax
Parameters
Installation language. Options:
en, es, fr, ruDatabase type. Options:
mysql_innodb, mysql, pgsql, sqliteDatabase host (e.g.,
localhost or 127.0.0.1)Database name
Database username
Database password
Database table prefix (can be empty)
Administrator username
Administrator password. Must be at least 16 characters or contain multiple words.
Administrator email address
Forum title
Forum description. Use
EMPTY for no description or provide text in quotes.Forum base URL (e.g.,
https://forum.example.com)Default language for the forum. Options:
en, es, fr, ruDefault theme/style. Default:
ForkBBCookie domain (can be empty)
Cookie path. Default:
/Whether to use secure cookies. Options:
1 (HTTPS only) or 0 (any)Example
send_mail
Processes the email queue and sends pending emails. This command is designed to be run periodically via cron or task scheduler.This command requires
config/main.php to exist (i.e., ForkBB must be installed).Syntax
Parameters
Logging level:
1- Log only when tasks are completed or the script cannot obtain an exclusive lock2- Log every execution regardless of result
Example
How It Works
- The command retrieves pending emails from the queue
- Each email is processed through the Mail service
- The queue uses exclusive locking to prevent concurrent execution
- Completed tasks are logged based on the
--logparameter - The result indicates the number of tasks completed (or
falseif locked)
test
A diagnostic command that writes a test entry to the ForkBB log to verify CLI functionality.This command requires
config/main.php to exist (i.e., ForkBB must be installed).Syntax
Example
Ok on success and logs the following information:
- PHP version
- PHP SAPI (always
cli) - Execution time
- User information (guest user)
Use this command to verify that the CLI environment is properly configured before running other commands.
Error Handling
Invalid Command
If you specify a command that doesn’t exist or isn’t available in the current context:Application Not Configured
If neitherconfig/main.php nor config/install.php exists:
Command Availability
- install: Only available when ForkBB is not yet installed
- test and send_mail: Only available when ForkBB is fully installed
Best Practices
Use absolute paths
Use absolute paths
When setting up automated tasks (cron jobs), always use absolute paths to the PHP binary and
cli.php script:Secure your credentials
Secure your credentials
When running the install command, ensure that your shell history doesn’t capture sensitive data. Consider using environment variables or configuration files for sensitive parameters.
Monitor log files
Monitor log files
Enable logging for send_mail operations to track email delivery and troubleshoot issues:
Test before automating
Test before automating
Before setting up cron jobs, manually test commands to ensure they work correctly in your environment.
Troubleshooting
Permission denied errors
Permission denied errors
Ensure the PHP CLI binary has execute permissions and the script is readable:
Database connection failures
Database connection failures
Verify that your database credentials are correct and the database server is accessible from the command line environment.
Email queue not processing
Email queue not processing
Check that:
- The database connection is working
- The mail configuration in
config/main.phpis correct - The send_mail command has proper file system permissions
- No other process has locked the queue
Related Resources
Installation Guide
Complete installation instructions including web-based setup
Configuration
Learn about ForkBB configuration options
Database Documentation
Database connection and query management
Container Service
Understanding the dependency injection container