====== Information ======
* MyBB ((https://mybb.com/))
* [[information:realm_of_espionage|Realm of Espionage]]
* https://forums.realmofespionage.xyz
===== Prerequisites =====
* [[windows;11_ltsc_server|Windows 11 (24H2)]]
* [[servers;windows;nginx_php_php-cgi|nginx + PHP + PHP-CGI]]
* [[servers;windows;nginx;lets_encrypt|Certbot (Let's Encrypt)]]
* [[programs;windows;git|Git]]
* [[servers;windows;mariadb|MariaDB]]
* TODO: ''listen = "127.0.0.1:9006"''
====== Dependencies ======
* https://docs.mybb.com/1.8/install/requirements/
* https://docs.mybb.com/1.8/install/anonymous-statistics/
====== Download Source ======
* https://github.com/mybb/mybb/commits/dev-1.9/
"%ProgramFiles%\Git\bin\git.exe" clone --branch "dev-1.9" --depth "1" --recurse-submodules "https://github.com/mybb/mybb.git" "%SystemDrive%\www\forum"
====== Database ======
"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p
CREATE DATABASE mybb;
CREATE USER 'mybb'@'localhost' IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON mybb.* to 'mybb'@'localhost';
FLUSH PRIVILEGES;
EXIT
====== Environment ======
===== PHP =====
"notepad.exe" "%SystemDrive%\www\php\forum.ini"
[PHP]
; Modules
extension_dir = ".\ext"
extension = "curl"
extension = "gd"
extension = "intl"
extension = "ldap"
extension = "mysqli"
extension = "openssl"
extension = "sodium"
; Settings
post_max_size = "5M"
upload_max_filesize = "5M"
error_reporting = "E_ERROR"
display_errors = "Off"
[Date]
date.timezone = "America/New_York"
; End
"php.exe" -c "%SystemDrive%\www\php\forum.ini" -m
===== Composer =====
* https://github.com/mybb/mybb/wiki/Getting-started-with-MyBB-1.9-development---Composer
* [[https://github.com/composer/composer/releases/latest/download/composer.phar|composer.phar]]
MKDIR "%SystemDrive%\www\ext"
"%SystemDrive%\www\ext\composer.phar"
"php.exe" -c "%SystemDrive%\www\php\forum.ini" "%SystemDrive%\www\ext\composer.phar" --version
CD "%SystemDrive%\www\forum" && "php.exe" -c "%SystemDrive%\www\php\forum.ini" "%SystemDrive%\www\ext\composer.phar" install --no-dev
====== nginx + PHP-FPM Configuration ======
===== PHP-FPM Socket =====
sudo -e '/etc/php8/fpm/php-fpm.d/forum.conf' && sudo systemctl restart 'php-fpm'
[forum]
; User/Group
user = "wwwrun"
group = "www"
; Socket
listen = "/run/php-fpm/forum.sock"
listen.owner = "wwwrun"
listen.group = "www"
listen.mode = "0662"
; Process Management
pm = "ondemand"
pm.max_children = "4"
pm.process_idle_timeout = "30"
; openSUSE php.ini Defaults
php_value[session.save_path] = "/var/lib/php8/sessions"
; General
php_value[log_errors] = "0"
php_value[error_reporting] = "~E_ALL"
php_value[date.timezone] = "America/New_York"
php_value[max_execution_time] = "200"
php_value[memory_limit] = "512M"
php_value[post_max_size] = "10M"
php_value[upload_max_filesize] = "10M"
php_value[max_file_uploads] = "100"
; End
===== FastCGI =====
* ''forum.sock''
sudo -e '/etc/nginx/default.d/forum.conf'
location ~ \.(php|phar)(/.*)?$ {
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/run/php-fpm/forum.sock;
}
# End
===== Server Block =====
sudo -e '/etc/nginx/vhosts.d/forum.conf' && sudo systemctl reload 'nginx'
server {
listen '443' 'ssl';
http2 'on';
server_name 'forums.realmofespionage.xyz';
root '/srv/www/forum';
index 'index.php';
include '/etc/nginx/default.d/forum.conf';
include '/etc/nginx/default.d/headers.conf';
client_max_body_size '10M';
# access_log /var/log/nginx/forum-access.log;
# error_log /var/log/nginx/forum-error.log;
}
# End
====== Scripts ======
===== Back-up =====
* TODO
"notepad.exe" "%SystemDrive%\www\scripts\media\Back-up.bat"
@echo off
:: User\Downloads
"tar.exe" -czf "%UserProfile%\Downloads\dokuwiki-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www\wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"
:: NAS
::"tar.exe" -czf "D:\Servers\Scheduled Backups\dokuwiki-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www\wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"
:: End
"%SystemDrive%\www\scripts\media\Back-up.bat"
===== Maintenance =====
"notepad.exe" "%SystemDrive%\www\scripts\media\Maintenance.bat"
@echo off
:: Piwigo
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" reset --hard
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" gc --aggressive --prune="all"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" fsck --full --strict
:: Bootstrap Darkroom
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" reset --hard
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" gc --aggressive --prune="all"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" fsck --full --strict
:: End
"%SystemDrive%\www\scripts\media\Maintenance.bat"
===== Git Fix =====
* :!: Set email for ''user.email''
"notepad.exe" "%SystemDrive%\www\scripts\forum\Git Fix.bat"
@echo off
RMDIR /S /Q "%SystemDrive%\www\forum\.git"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" init --initial-branch="dev-1.9"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" add "."
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" config "user.email" "espionage724@x"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" commit --message="x"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" remote add "origin" "https://github.com/mybb/mybb.git"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" pull --depth "1" --recurse-submodules "origin" "dev-1.9" --rebase
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" reset --hard "origin/dev-1.9"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" gc --aggressive --prune="all"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\forum" fsck --full --strict
PAUSE
:: End
"%SystemDrive%\www\scripts\forum\Git Fix.bat"
====== Initial Setup ======
* https://forums.realmofespionage.xyz
====== Settings ======
* TODO
===== Offline Message =====
* Configuration -> Settings -> Board Online / Offline
These forums are being built behind-the-scenes, check back later!
In the meantime, check out my wiki: RoE | Wiki
===== config.php =====
* https://docs.mybb.com/1.8/administration/utf-8-setup/
sudo su 'wwwrun' -s '/bin/bash'
nano '/srv/www/forum/inc/config.php'
$config['database']['encoding'] = 'utf8mb4';
exit
====== Services ======
===== Updater =====
==== Service ====
sudo -e '/etc/systemd/system/forum-up.service'
[Service]
User=wwwrun
Group=www
Type=oneshot
Environment="COMPOSER_CACHE_DIR=/dev/null"
ExecStart='/usr/bin/git' -C '/srv/www/forum' pull origin 'dev-1.9'
ExecStart='/usr/bin/composer' --working-dir='/srv/www/forum' --no-cache install
ExecStartPost='/usr/bin/sync'
# End
==== Timer ====
* Every day at ''05:00:00''
sudo -e '/etc/systemd/system/forum-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-up.timer' --now && sudo systemctl start 'forum-up' && sudo systemctl status 'forum-up' -l
[Unit]
Description=MyBB Git Updater
After=network-online.target
Wants=network-online.target
[Timer]
OnCalendar=*-*-* 05:00:00
Persistent=true
[Install]
WantedBy=timers.target
# End
===== Backup =====
==== Files ====
=== Service ===
mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/forum-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/forum-fb.service'
[Service]
Type=oneshot
ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/mybb-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/www" "forum"'
ExecStartPost='/usr/bin/sync'
# End
=== Timer ===
* ''01'' day of every month at ''05:15:00''
sudo -e '/etc/systemd/system/forum-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-fb.timer' --now
[Unit]
Description=MyBB Files Backup
[Timer]
OnCalendar=*-*-01 05:15:00
Persistent=true
[Install]
WantedBy=timers.target
# End
sudo systemctl start 'forum-fb' && sudo systemctl status 'forum-fb' -l
==== Database ====
=== Database Auth ===
sudo mkdir -p '/var/lib/mysql/auth' && sudo -e '/var/lib/mysql/auth/mybb' && sudo chown 'mysql':'mysql' '/var/lib/mysql/auth/mybb' && sudo chmod '0600' '/var/lib/mysql/auth/mybb'
[mariadb-dump]
user=mybb
password=x
# End
=== Service ===
mkdir -p ~/'backups' && sudo mkdir -p '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/forum-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/forum-db.service'
[Service]
Group=mysql
Type=oneshot
ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/var/lib/mysql/auth/mybb" --single-transaction --quick "mybb" -r "/home/CHANGEME/backups/mybb-database-auto-"$$(date +%%Y-%%m-%%d)".sql"'
ExecStartPost='/usr/bin/sync'
# End
=== Timer ===
* ''01'' day of every month at ''05:10:00''
sudo -e '/etc/systemd/system/forum-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-db.timer' --now && sudo systemctl start 'forum-db' && sudo systemctl status 'forum-db' -l
[Unit]
Description=mybb Database Backup
After=mariadb.service
[Timer]
OnCalendar=*-*-01 05:10:00
Persistent=true
[Install]
WantedBy=timers.target
# End
===== Maintenance =====
==== Service ====
sudo -e '/etc/systemd/system/forum-m.service'
[Service]
User=wwwrun
Group=www
Type=oneshot
ExecStart='/usr/bin/git' -C '/srv/www/forum' reset --hard
ExecStart='/usr/bin/git' -C '/srv/www/forum' gc --aggressive --prune='all'
ExecStart='/usr/bin/git' -C '/srv/www/forum' fsck --full --strict
ExecStartPost='/usr/bin/sync'
# End
==== Timer ====
* ''01'' day of every month at ''05:30:00''
sudo -e '/etc/systemd/system/forum-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-m.timer' --now
[Unit]
Description=MyBB Maintenance
After=network-online.target
Wants=network-online.target
[Timer]
OnCalendar=*-*-01 05:30:00
Persistent=true
[Install]
WantedBy=timers.target
# End
sudo systemctl start 'forum-m' && sudo systemctl status 'forum-m' -l
====== Files ======
===== Backup =====
****
"tar.exe" -czf "%UserProfile%\Downloads\mybb-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "forum"
====== Database ======
===== Backup =====
****
CD "%UserProfile%\Downloads" && "%ProgramFiles%\MariaDB 12.1\bin\mariadb-dump.exe" -u "root" -p --opt -r "mybb.sql" "mybb"
===== Restore =====
* [[#database|Initial set-up]]
"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p --execute="CREATE DATABASE mybb"
"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p "mybb" < "%UserProfile%\Downloads\mybb.sql"