User Tools

Site Tools


servers:bsd:nginx:mybb

This is an old revision of the document!


Information

Prerequisites

Dependencies

Download Source

su -
git clone --branch 'feature' --depth '1' --recurse-submodules 'https://github.com/mybb/mybb.git' '/usr/local/www/forum' && chown -R 'www':'www' '/usr/local/www/forum'

Database

su -
mariadb
CREATE DATABASE mybb;
CREATE USER mybb@localhost IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON mybb.* to mybb@localhost;
FLUSH PRIVILEGES;EXIT;

nginx + PHP-FPM Configuration

PHP-FPM Socket

su -
ee '/usr/local/etc/php-fpm.d/forum.conf' && service 'php_fpm' reload
[forum]

; User/Group
user = "www"
group = "www"

; Socket
listen = "127.0.0.1:9006"
listen.allowed_clients = "127.0.0.1"

; Process Management
pm = "ondemand"
pm.max_children = "4"
pm.process_idle_timeout = "30"

; Logging
php_value[log_errors] = "Off"
php_value[error_reporting] = "~E_ALL"
php_value[display_errors] = "Off"
php_value[display_startup_errors] = "Off"
php_value[html_errors] = "Off"

; General
php_value[date.timezone] = "America/New_York"

; End

FastCGI

su -
ee '/usr/local/etc/freenginx/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_param 'HTTPS' 'on';

 fastcgi_pass '127.0.0.1:9006';
}

# End

Server Block

su -
ee '/usr/local/etc/freenginx/vhosts.d/forum.conf' && service 'nginx' reload
server {
 listen '443' 'ssl';
 http2 'on';
 server_name 'forums.realmofespionage.xyz';
 root '/usr/local/www/forum';
 index 'index.php';

 include '/usr/local/etc/freenginx/default.d/forum.conf';
 include '/usr/local/etc/freenginx/default.d/headers.conf';

# access_log '/var/log/nginx/forum-access.log';
# error_log '/var/log/nginx/forum-error.log';

 location '/' {
  rewrite '^/forum-([0-9]+)\.html$' '/forumdisplay.php?fid=$1';
  rewrite '^/forum-([0-9]+)-page-([0-9]+)\.html$' '/forumdisplay.php?fid=$1&page=$2';
  rewrite '^/thread-([0-9]+)\.html$' '/showthread.php?tid=$1';
  rewrite '^/thread-([0-9]+)-page-([0-9]+)\.html$' '/showthread.php?tid=$1&page=$2';
  rewrite '^/thread-([0-9]+)-lastpost\.html$' '/showthread.php?tid=$1&action=lastpost';
  rewrite '^/thread-([0-9]+)-nextnewest\.html$' '/showthread.php?tid=$1&action=nextnewest';
  rewrite '^/thread-([0-9]+)-nextoldest\.html$' '/showthread.php?tid=$1&action=nextoldest';
  rewrite '^/thread-([0-9]+)-newpost\.html$' '/showthread.php?tid=$1&action=newpost';
  rewrite '^/thread-([0-9]+)-post-([0-9]+)\.html$' '/showthread.php?tid=$1&pid=$2';

  rewrite '^/post-([0-9]+)\.html$' '/showthread.php?pid=$1';

  rewrite '^/announcement-([0-9]+)\.html$' '/announcements.php?aid=$1';

  rewrite '^/user-([0-9]+)\.html$' '/member.php?action=profile&uid=$1';

  rewrite '^/calendar-([0-9]+)\.html$' '/calendar.php?calendar=$1';
  rewrite '^/calendar-([0-9]+)-year-([0-9]+)\.html$' '/calendar.php?action=yearview&calendar=$1&year=$2';
  rewrite '^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$' '/calendar.php?calendar=$1&year=$2&month=$3';
  rewrite '^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$' '/calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4';
  rewrite '^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$' '/calendar.php?action=weekview&calendar=$1&week=$2';

  rewrite '^/event-([0-9]+)\.html$' '/calendar.php?action=event&eid=$1';
 }
}

# End

Initial Setup

  • Database Engine: MySQL Improved
  • Database Server Hostname: 127.0.0.1
  • Table Encoding: 4-Byte UTF-8 Unicode

Settings

  • TODO

Offline Message

  • Configuration → Settings → Board Online / Offline
These forums are being built behind-the-scenes, check back later!
<br />
In the meantime, check out my wiki: <a href="https://wiki.realmofespionage.xyz/">RoE | Wiki</a>

Scripts

Updater

mkdir -p ~/'.local/scripts/www/forum' && ee ~/'.local/scripts/www/forum/updater.sh' && chmod +x ~/'.local/scripts/www/forum/updater.sh'
#!/bin/sh

'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' reset --hard 'origin/feature'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' pull 'origin' 'feature' --rebase"

# End
su 'root' -c ~/'.local/scripts/www/forum/updater.sh'

Backup

mkdir -p ~/'backups' ~/'.local/scripts/www/forum' && ee ~/'.local/scripts/www/forum/backup.sh' && chmod +x ~/'.local/scripts/www/forum/backup.sh'
#!/bin/sh

cd '/tmp'

'/usr/bin/tar' -czf '/home/espionage724/backups/mybb-files-auto-'$(date +%Y-%m-%d)'.tar.gz' -C '/usr/local/www' 'forum'

'/usr/local/bin/mariadb-dump' --single-transaction --quick 'mybb' -r '/home/espionage724/backups/mybb-database-auto-'$(date +%Y-%m-%d)'.sql'

'/bin/sync'

# End
su 'root' -c ~/'.local/scripts/www/forum/backup.sh'

Maintenance

mkdir -p ~/'.local/scripts/www/forum' && ee ~/'.local/scripts/www/forum/maintenance.sh' && chmod +x ~/'.local/scripts/www/forum/maintenance.sh'
#!/bin/sh

cd '/tmp'

'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' gc --aggressive --prune='all'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' fsck --full --strict"

# End
su 'root' -c ~/'.local/scripts/www/forum/maintenance.sh'

Git Fix

  • :!: Set email for user.email
mkdir -p ~/'.local/scripts/www/forum' && ee ~/'.local/scripts/www/forum/git-fix.sh' && chmod +x ~/'.local/scripts/www/forum/git-fix.sh'
#!/bin/sh

cd '/tmp'

'/usr/bin/su' -m 'www' -c "'/bin/rm' -Rf '/usr/local/www/forum/.git'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' init --initial-branch='feature'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' add '.'"

########################################
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' config 'user.email' 'espionage724@x'"
########################################

'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' commit --message='x'"

'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' remote add 'origin' 'https://github.com/mybb/mybb.git'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' pull --depth '1' --recurse-submodules 'origin' 'feature' --rebase"

'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' reset --hard 'origin/feature'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' gc --aggressive --prune='all'"
'/usr/bin/su' -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/forum' fsck --full --strict"

'/bin/sync'

# End
su 'root' -c ~/'.local/scripts/www/forum/git-fix.sh'

cron

Updater

  • Daily 05:00:00 AM
su -
ee '/etc/cron.d/forum-updater'
#
SHELL=/bin/sh

0 5 * * * root '/home/espionage724/.local/scripts/www/forum/updater.sh'

# End

Backup

  • Monthly (6th) 05:10:00 AM
su -
ee '/etc/cron.d/forum-backup'
#
SHELL=/bin/sh

10 5 6 * * root '/home/espionage724/.local/scripts/www/forum/backup.sh'

# End

Maintenance

  • Monthly (6th) 05:30:00 AM
su -
ee '/etc/cron.d/forum-maintenance'
#
SHELL=/bin/sh

30 5 6 * * root '/home/espionage724/.local/scripts/www/forum/maintenance.sh'

# End

Backup

Folder

su -
tar -czf '/home/espionage724/mybb-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/usr/local/www' 'forum'

Database

su -
mariadb-dump --single-transaction --quick 'mybb' -r '/home/espionage724/mybb-database-manual-'$(date +%Y-%m-%d)'.sql'

scp

scp espionage724@192.168.1.152:~/'mybb-files-'*'.tar.gz' espionage724@192.168.1.152:~/'mybb-database-'*'.sql' ~/'Downloads'

Restore

scp

scp ~/'Downloads/mybb-files-'*'.tar.gz' ~/'Downloads/mybb'*'.sql' espionage724@192.168.1.152:~

Folder

su
rm -Rf '/usr/local/www/forum'
tar -xzf '/home/'$USER'/mybb-files-'*'.tar.gz' -C '/usr/local/www' 'forum' && chown -R 'www':'www' '/usr/local/www/forum' && sync

Database

su
mariadb --execute='CREATE DATABASE mybb;'
cat '/home/'$USER/'mybb'*'.sql' | mariadb 'mybb'

MySQL Connection

su -
su -m 'www' -c "ee '/usr/local/www/forum/inc/config.php'"
$config['database']['hostname'] = '127.0.0.1';
/usr/local/www/wiki/data/attic/servers/bsd/nginx/mybb.1767987616.txt.gz · Last modified: by Sean Rhone

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki