Both sides previous revisionPrevious revisionNext revision | Previous revision |
servers:bsd:nginx:dokuwiki [2024/12/02 16:28] – Sean Rhone | servers:bsd:nginx:dokuwiki [2025/05/24 05:34] (current) – Sean Rhone |
---|
====== Information ====== | ====== Information ====== |
| |
* DokuWiki ((https://www.dokuwiki.org)) ((https://github.com/splitbrain/dokuwiki)) | * DokuWiki ((https://www.dokuwiki.org)) |
* :!: ''php84'' branch ((https://github.com/dokuwiki/dokuwiki/tree/php84)) ([[https://github.com/dokuwiki/dokuwiki/pull/4360|#4360]]) | |
* [[Information:Realm of Espionage]] | * [[Information:Realm of Espionage]] |
* https://wiki.realmofespionage.xyz ((you are here :p)) | * https://wiki.realmofespionage.xyz ((you are here :p)) |
| |
* [[bsd:server:freebsd_14.2|FreeBSD 14.2]] | * [[bsd:server:freebsd_14.2|FreeBSD 14.2]] |
* [[servers:bsd:freenginx_php_php-fpm|freenginx + PHP + PHP-FPM]] | * [[servers:bsd:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] |
* [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]] | * [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]] |
| |
* :!: 2024/11/30: WIP | |
* :!: 2024/12/02: ''php84'' looks merged with ''master'' ([[https://github.com/dokuwiki/dokuwiki/commit/8be857f350c80b12ba3a8c8d59414b1d7fcd9a02|commit]]) | |
| |
====== TODOs ====== | |
| |
* https://www.dokuwiki.org/cli?s%5B%5D=wantedpages.php | |
* https://www.dokuwiki.org/rewrite | |
* Bootstrap/modern theme (if it looks good with rolling ''master'' support) | |
| |
====== Dependencies ====== | ====== Dependencies ====== |
su - | su - |
| |
pkg install git php84-filter php84-gd php84-sodium php84-zip php84-xml php84-session php84-bz2 php84-intl php84-mbstring php84-zlib | pkg install git-lite php84-session php84-bz2 php84-filter php84-gd php84-intl php84-mbstring php84-xml php84-zlib |
| |
====== Download Source ====== | ====== Download Source ====== |
| |
| * https://github.com/dokuwiki/dokuwiki/commits/master/ |
| |
su - | su - |
| |
git clone --branch 'php84' --depth '1' --recurse-submodules 'https://github.com/splitbrain/dokuwiki.git' '/usr/local/www/wiki' && chown -R 'www':'www' '/usr/local/www/wiki' && sync | git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/splitbrain/dokuwiki.git' '/usr/local/www/wiki' && chown -R 'www':'www' '/usr/local/www/wiki' && sync |
| |
====== nginx + PHP-FPM Configuration ====== | ====== nginx + PHP-FPM Configuration ====== |
fastcgi_param HTTPS on; | fastcgi_param HTTPS on; |
fastcgi_pass 127.0.0.1:9002; | fastcgi_pass 127.0.0.1:9002; |
}</code> | } |
| |
| # End</code> |
| |
===== Server Block ====== | ===== Server Block ====== |
server { | server { |
listen '443' 'ssl'; | listen '443' 'ssl'; |
http2 'on'; | # http2 'on'; |
server_name 'wiki.realmofespionage.xyz'; | server_name 'wiki.realmofespionage.xyz'; |
root '/usr/local/www/wiki'; | root '/usr/local/www/wiki'; |
rewrite ^/(.*) /doku.php?id=$1&$args last; | rewrite ^/(.*) /doku.php?id=$1&$args last; |
} | } |
}</code> | } |
| |
| # End</code> |
| |
====== Initial Setup ====== | ====== Initial Setup ====== |
===== Update ===== | ===== Update ===== |
| |
* https://github.com/dokuwiki/dokuwiki/commits/php84/ | * https://github.com/dokuwiki/dokuwiki/commits/master/ |
| |
su - | su - |
| |
su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' pull origin 'php84'" | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' pull origin 'master'" |
| |
===== Indexer ===== | ===== Indexer ===== |
| |
su -m 'www' -c "cd '/usr/local/www/wiki' && '/usr/local/www/wiki/bin/indexer.php' --clear" | su -m 'www' -c "cd '/usr/local/www/wiki' && '/usr/local/www/wiki/bin/indexer.php' --clear" |
| |
====== Services ====== | |
| |
===== Updater ===== | |
| |
==== Service ==== | |
| |
sudo -e '/etc/systemd/system/wiki-up.service' | |
| |
<code> | |
[Service] | |
User=nginx | |
Group=nginx | |
Type=oneshot | |
ExecStart='/usr/bin/git' -C '/var/www/wiki' pull origin 'master' | |
ExecStartPost='/usr/bin/touch' '/var/www/wiki/conf/local.php' | |
ExecStartPost='/usr/bin/sync' | |
| |
# End</code> | |
| |
==== Timer ==== | |
| |
* Every day at ''00:30:00'' | |
| |
sudo -e '/etc/systemd/system/wiki-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'wiki-up.timer' --now && sudo systemctl start 'wiki-up' && sudo systemctl status 'wiki-up' -l | |
| |
<code> | |
[Unit] | |
Description=DokuWiki Git Updater | |
After=network-online.target | |
Wants=network-online.target | |
| |
[Timer] | |
OnCalendar=*-*-* 00:30:00 | |
Persistent=true | |
| |
[Install] | |
WantedBy=timers.target | |
| |
# End</code> | |
| |
===== Maintenance ===== | ===== Maintenance ===== |
| |
* https://www.dokuwiki.org/tips:maintenance | su - |
| |
==== Service ==== | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' reset --hard" |
| |
* :!: The commented ''ExecStart'' would remove page edits older than 90 days | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' pull origin 'master' --rebase" |
| |
sudo -e '/etc/systemd/system/wiki-m.service' | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' gc --aggressive --prune='all'" |
| |
<code> | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' fsck --full --strict" |
[Service] | |
User=nginx | |
Group=nginx | |
Type=oneshot | |
WorkingDirectory=/var/www/wiki | |
ExecStart='/usr/bin/git' -C '/var/www/wiki' gc --aggressive --prune='all' | |
ExecStart='/usr/bin/git' -C '/var/www/wiki' fsck --full --strict | |
#ExecStart='/usr/bin/bash' -c "find '/var/www/wiki/data'/{attic,cache,locks,media_attic}/ -type 'f' -mtime +'90' -delete" | |
ExecStart='/usr/bin/bash' -c "find '/var/www/wiki/data'/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp}/ -mindepth '1' -type 'd' -empty -delete" | |
ExecStart='/usr/bin/php' '/var/www/wiki/bin/indexer.php' --clear | |
ExecStartPost='/usr/bin/sync' | |
| |
# End</code> | |
| |
==== Timer ==== | |
| |
* ''01'' day of every month at ''01:00:00'' | |
| |
sudo -e '/etc/systemd/system/wiki-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'wiki-m.timer' --now | |
| |
<code> | |
[Unit] | |
Description=DokuWiki Maintenance | |
| |
[Timer] | |
OnCalendar=*-*-01 01:00:00 | |
Persistent=true | |
| |
[Install] | |
WantedBy=timers.target | |
| |
# End</code> | |
| |
===== Backup ===== | |
| |
* This backs up an archive to the local disk and to a NAS | |
| |
==== Service ==== | |
| |
* The extra ''ExecStart''s are additional backup locations that expect [[servers:linux:vsftpd#fstab1|vsftpd]] | |
* TODO: Remove additional backup locations and put it on a system-wide script direct from the ''~/backups'' folder | |
| |
mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/wiki-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/wiki-fb.service' | |
| |
<code> | |
[Service] | |
Type=oneshot | |
WorkingDirectory=/var/www/wiki | |
ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/dokuwiki-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"' | |
#ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/var/ftp/nas1/Servers/Scheduled Backups/dokuwiki-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"' | |
#ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/srv/ftp/nas2/Servers/Scheduled Backups/dokuwiki-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"' | |
ExecStartPost='/usr/bin/sync' | |
| |
# End</code> | |
| |
==== Timer ==== | |
| |
* Every day at ''01:30:00'' | |
| |
sudo -e '/etc/systemd/system/wiki-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'wiki-fb.timer' --now && sudo systemctl start 'wiki-fb' && sudo systemctl status 'wiki-fb' -l | |
| |
<code> | |
[Unit] | |
Description=DokuWiki Files Backup | |
| |
[Timer] | |
OnCalendar=*-*-* 01:30:00 | |
Persistent=true | |
| |
[Install] | |
WantedBy=timers.target | |
| |
# End</code> | |
| |
====== Backup ====== | ====== Backup ====== |
| |
* Create backup archive on server and transfer to client computer | ===== Folder ===== |
| |
===== Server ===== | su - |
| |
==== Archive Folders ==== | cd '/usr/local/www/wiki' && tar -cvzf '/home/espionage724/dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sync |
| |
**** | ===== scp ===== |
| |
cd '/var/www/wiki' && sudo tar -cvzf ~/'dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && cd ~ && sync | |
| |
===== Client ===== | |
| |
==== Transfer Archive to Client ==== | |
| |
**** | **** |
====== Restore ====== | ====== Restore ====== |
| |
===== Client ===== | ===== scp ===== |
| |
==== Transfer Archive to Server ==== | |
| |
**** | **** |
scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.152:~ | scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.152:~ |
| |
==== Remove Archive ==== | ===== Folder ===== |
| |
**** | |
| |
rm ~/'Downloads/dokuwiki-files-'*'.tar.gz' && sync | |
| |
===== Server ===== | |
| |
==== Stop nginx ==== | |
| |
su - | su - |
| |
service 'nginx' stop | ls '/home/espionage724/dokuwiki-files-'*'.tar.gz' && rm -Rf '/usr/local/www/wiki/data/pages' '/usr/local/www/wiki/data/meta' '/usr/local/www/wiki/data/media' '/usr/local/www/wiki/data/media_meta' '/usr/local/www/wiki/data/attic' '/usr/local/www/wiki/data/media_attic' '/usr/local/www/wiki/conf' |
| |
==== Remove Previous Folders ==== | |
| |
su - | |
| |
ls '/home/'*'/dokuwiki-files-'*'.tar.gz' && rm -Rf '/usr/local/www/wiki/data/pages' '/usr/local/www/wiki/data/meta' '/usr/local/www/wiki/data/media' '/usr/local/www/wiki/data/media_meta' '/usr/local/www/wiki/data/attic' '/usr/local/www/wiki/data/media_attic' '/usr/local/www/wiki/conf' | |
| |
==== Restore Folders ==== | |
| |
su - | |
| |
cd '/usr/local/www/wiki' && tar -xvzf '/home/'*'/dokuwiki-files-'*'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && chown -R 'www':'www' '/usr/local/www/wiki' && cd ~ && sync | |
| |
==== Start nginx ==== | |
| |
su - | |
| |
service 'nginx' start | |
| |
==== Remove Archive ==== | |
| |
* Verify that DokuWiki works before running | |
| |
rm -R ~/'dokuwiki-files-'*'.tar.gz' && sync | cd '/usr/local/www/wiki' && tar -xvzf '/home/espionage724/dokuwiki-files-'*'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && chown -R 'www':'www' '/usr/local/www/wiki' && cd ~ && sync |
| |