| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| servers:linux:nginx:mybb [2025/12/22 03:54] – [Server Block] Sean Rhone | servers:linux:nginx:mybb [2025/12/22 04:47] (current) – [Restore Files] Sean Rhone |
|---|
| |
| ===== Server Block ====== | ===== Server Block ====== |
| | |
| | * https://docs.mybb.com/1.8/administration/configuring-search-engine-friendly-URLs/ |
| |
| sudo -e '/etc/nginx/sites-available/forum.conf' | sudo -e '/etc/nginx/sites-available/forum.conf' |
| |
| location '/' { | location '/' { |
| rewrite ^/forum-([0-9]+)\.html$ /forumdisplay.php?fid=$1; | rewrite '^/forum-([0-9]+)\.html$' '/forumdisplay.php?fid=$1'; |
| rewrite ^/forum-([0-9]+)-page-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2; | 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]+)\.html$' '/showthread.php?tid=$1'; |
| rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&page=$2; | 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]+)-lastpost\.html$' '/showthread.php?tid=$1&action=lastpost'; |
| rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&action=nextnewest; | 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]+)-nextoldest\.html$' '/showthread.php?tid=$1&action=nextoldest'; |
| rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&action=newpost; | 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 '^/thread-([0-9]+)-post-([0-9]+)\.html$' '/showthread.php?tid=$1&pid=$2'; |
| |
| rewrite ^/post-([0-9]+)\.html$ /showthread.php?pid=$1; | rewrite '^/post-([0-9]+)\.html$' '/showthread.php?pid=$1'; |
| |
| rewrite ^/announcement-([0-9]+)\.html$ /announcements.php?aid=$1; | rewrite '^/announcement-([0-9]+)\.html$' '/announcements.php?aid=$1'; |
| |
| rewrite ^/user-([0-9]+)\.html$ /member.php?action=profile&uid=$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]+)\.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]+)\.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]+)\.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]+)-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 '^/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; | rewrite '^/event-([0-9]+)\.html$' '/calendar.php?action=event&eid=$1'; |
| } | } |
| |
| **** | **** |
| |
| sudo -u 'www-data' -e '/var/www/forum/inc/config.php'ww/forum/inc/config.php' | sudo -u 'www-data' -e '/var/www/forum/inc/config.php' |
| | |
| | ====== Scripts ====== |
| | |
| | ===== Git Fix ===== |
| | |
| | * :!: Set email for ''user.email'' |
| | |
| | sudo mkdir -p '/etc/nginx/scripts/forum' && sudo -e '/etc/nginx/scripts/forum/git-fix.sh' && sudo chmod '0500' '/etc/nginx/scripts/forum/git-fix.sh' && sudo chown 'www-data':'www-data' '/etc/nginx/scripts/forum/git-fix.sh' |
| | |
| | <code> |
| | #!/bin/bash |
| | |
| | cd '/tmp' |
| | |
| | '/usr/bin/rm' -Rf '/var/www/forum/.git' |
| | '/usr/bin/git' -C '/var/www/forum' init --initial-branch='feature' |
| | '/usr/bin/git' -C '/var/www/forum' add '.' |
| | |
| | ######################################## |
| | '/usr/bin/git' -C '/var/www/forum' config 'user.email' 'espionage724@x' |
| | ######################################## |
| | |
| | '/usr/bin/git' -C '/var/www/forum' commit --message='x' |
| | |
| | '/usr/bin/git' -C '/var/www/forum' remote add 'origin' 'https://github.com/mybb/mybb.git' |
| | '/usr/bin/git' -C '/var/www/forum' pull --depth '1' --recurse-submodules 'origin' 'feature' --rebase |
| | |
| | '/usr/bin/git' -C '/var/www/forum' reset --hard 'origin/feature' |
| | '/usr/bin/git' -C '/var/www/forum' gc --aggressive --prune='all' |
| | '/usr/bin/git' -C '/var/www/forum' fsck --full --strict |
| | |
| | # End</code> |
| | |
| | sudo -u 'www-data' '/etc/nginx/scripts/forum/git-fix.sh' |
| |
| ====== Services ====== | ====== Services ====== |
| [Service] | [Service] |
| User=www-data | User=www-data |
| Group=www | Group=www-data |
| Type=oneshot | Type=oneshot |
| |
| Environment="COMPOSER_CACHE_DIR=/dev/null" | WorkingDirectory=/var/www/forum |
| |
| ExecStart='/usr/bin/git' -C '/var/www/forum' pull origin 'feature' | ExecStart='/usr/bin/git' -C '/var/www/forum' reset --hard 'origin/feature' |
| | ExecStart='/usr/bin/git' -C '/var/www/forum' pull origin 'feature' --rebase |
| ExecStart='/usr/bin/composer' --working-dir='/var/www/forum' --no-cache install --no-dev | |
| |
| ExecStartPost='/usr/bin/sync' | ExecStartPost='/usr/bin/sync' |
| ==== Timer ==== | ==== Timer ==== |
| |
| * Every day at ''05:00:00'' | * Daily ''05:00:00 AM'' |
| |
| 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 | 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 |
| [Service] | [Service] |
| Type=oneshot | Type=oneshot |
| | |
| | WorkingDirectory=/var/www/forum |
| |
| ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/mybb-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/var/www" "forum"' | ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/mybb-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/var/www" "forum"' |
| === Timer === | === Timer === |
| |
| * ''01'' day of every month at ''05:15:00'' | * Monthly (6th) ''05:15:00 AM'' |
| |
| sudo -e '/etc/systemd/system/forum-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-fb.timer' --now | sudo -e '/etc/systemd/system/forum-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-fb.timer' --now |
| |
| [Timer] | [Timer] |
| OnCalendar=*-*-01 05:15:00 | OnCalendar=*-*-06 05:15:00 |
| Persistent=true | Persistent=true |
| |
| Group=mysql | Group=mysql |
| Type=oneshot | Type=oneshot |
| | |
| | WorkingDirectory=/var/lib/mysql |
| |
| 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"' | 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"' |
| === Timer === | === Timer === |
| |
| * ''01'' day of every month at ''05:10:00'' | * Monthly (6th) ''05:10:00 AM'' |
| |
| 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 | 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 |
| |
| [Timer] | [Timer] |
| OnCalendar=*-*-01 05:10:00 | OnCalendar=*-*-06 05:10:00 |
| Persistent=true | Persistent=true |
| |
| [Service] | [Service] |
| User=www-data | User=www-data |
| Group=www | Group=www-data |
| Type=oneshot | Type=oneshot |
| |
| ExecStart='/usr/bin/git' -C '/var/www/forum' reset --hard | WorkingDirectory=/var/www/forum |
| ExecStart='/usr/bin/git' -C '/var/www/forum' gc --aggressive --prune='all' | ExecStart='/usr/bin/git' -C '/var/www/forum' gc --aggressive --prune='all' |
| ExecStart='/usr/bin/git' -C '/var/www/forum' fsck --full --strict | ExecStart='/usr/bin/git' -C '/var/www/forum' fsck --full --strict |
| ==== Timer ==== | ==== Timer ==== |
| |
| * ''01'' day of every month at ''05:30:00'' | * Monthly (6th) ''05:30:00 AM'' |
| |
| sudo -e '/etc/systemd/system/forum-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-m.timer' --now | sudo -e '/etc/systemd/system/forum-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'forum-m.timer' --now |
| |
| [Timer] | [Timer] |
| OnCalendar=*-*-01 05:30:00 | OnCalendar=*-*-06 05:30:00 |
| Persistent=true | Persistent=true |
| |
| **** | **** |
| |
| sudo tar -xzf ~/'mybb-files-'*'.tar.gz' -C '/var/www' 'forum' && sudo chown -R 'www-data':'www' '/var/www/forum' && sudo chmod -R '0755' '/var/www/forum' | sudo tar -xzf ~/'mybb-files-'*'.tar.gz' -C '/var/www' 'forum' && sudo chown -R 'www-data':'www-data' '/var/www/forum' && sudo chmod -R '0755' '/var/www/forum' |
| |
| ===== Git Fix ===== | ===== Git Fix ===== |