Both sides previous revisionPrevious revisionNext revision | Previous revision |
servers:bsd:nginx:dokuwiki [2025/05/16 21:50] – Sean Rhone | servers:bsd:nginx:dokuwiki [2025/09/11 06:43] (current) – external edit 127.0.0.1 |
---|
====== Information ====== | ====== Information ====== |
| |
* DokuWiki ((https://www.dokuwiki.org)) ((https://github.com/splitbrain/dokuwiki)) | * DokuWiki ((https://www.dokuwiki.org)) |
* [[Information:Realm of Espionage]] | * [[Information:Realm of Espionage]] |
* https://wiki.realmofespionage.xyz ((you are here :p)) | * https://wiki.realmofespionage.xyz ((you are here :p)) |
===== Prerequisites ===== | ===== Prerequisites ===== |
| |
* [[bsd:server:freebsd_14.2|FreeBSD 14.2]] | * [[bsd:server:freebsd_14.3|FreeBSD 14.3]] |
* [[servers:bsd:nginx_php_php-fpm|nginx + 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]] |
| |
====== Download Source ====== | ====== Download Source ====== |
| |
| * https://github.com/dokuwiki/dokuwiki/commits/master/ |
| |
su - | su - |
| |
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 | 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' |
| |
====== nginx + PHP-FPM Configuration ====== | ====== nginx + PHP-FPM Configuration ====== |
su - | su - |
| |
ee '/usr/local/etc/php-fpm.d/wiki.conf' && service 'php_fpm' restart | ee '/usr/local/etc/php-fpm.d/wiki.conf' && service 'php_fpm' reload |
| |
<code> | <code> |
| |
<code> | <code> |
# PHP-FPM | |
location ~ \.(php|phar)(/.*)?$ { | location ~ \.(php|phar)(/.*)?$ { |
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$; | fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$; |
su - | su - |
| |
ee '/usr/local/etc/nginx/vhosts.d/wiki.conf' && service 'nginx' reload && sync | ee '/usr/local/etc/nginx/vhosts.d/wiki.conf' && service 'nginx' reload |
| |
<code> | <code> |
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'; |
* Do after initial setup | * Do after initial setup |
| |
sudo -e '/etc/nginx/vhosts.d/wiki.conf' && sudo systemctl reload 'nginx' | su - |
| |
| ee '/usr/local/etc/nginx/vhosts.d/wiki.conf' && service 'nginx' reload |
| |
===== URL Rewrite ===== | ===== URL Rewrite ===== |
| |
* This prevents -- from becoming a – (long hyphen), which breaks some command's syntax | * This prevents -- from becoming a – (long hyphen), which breaks some command's syntax |
| * :!: TODO: FreeBSD |
| |
echo '-- --' | sudo tee '/var/www/wiki/conf/entities.local.conf' > '/dev/null' && sudo chown 'nginx':'nginx' '/var/www/wiki/conf/entities.local.conf' && sync | echo '-- --' | sudo tee '/var/www/wiki/conf/entities.local.conf' > '/dev/null' && sudo chown 'nginx':'nginx' '/var/www/wiki/conf/entities.local.conf' && sync |
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" |
| |
===== Etc ===== | ===== Maintenance ===== |
| |
su - | su - |
| |
su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' fsck --full --strict" | su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' fsck --full --strict" |
| |
====== 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 ===== | |
| |
* https://www.dokuwiki.org/tips:maintenance | |
| |
==== Service ==== | |
| |
* :!: The commented ''ExecStart'' would remove page edits older than 90 days | |
| |
sudo -e '/etc/systemd/system/wiki-m.service' | |
| |
<code> | |
[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 ===== | |
| |
==== Archive Folders ==== | |
| |
su - | su - |
| |
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 | tar -czf '/home/espionage724/dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/usr/local/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' |
| |
===== Client ===== | ===== scp ===== |
| |
==== Transfer Archive to Client ==== | |
| |
**** | **** |
| |
scp espionage724@192.168.1.152:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' && sync | scp espionage724@192.168.1.152:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' |
| |
====== 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 | tar -xzf '/home/espionage724/dokuwiki-files-'*'.tar.gz' -C '/usr/local/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && chown -R 'www':'www' '/usr/local/www/wiki' && sync |
| |