Both sides previous revisionPrevious revisionNext revision | Previous revision |
servers:linux:nginx:dokuwiki [2025/05/16 21:39] – external edit 127.0.0.1 | servers:linux:nginx:dokuwiki [2025/07/16 14:06] (current) – [Service] Sean Rhone |
---|
* https://github.com/dokuwiki/dokuwiki/commits/master/ | * https://github.com/dokuwiki/dokuwiki/commits/master/ |
| |
sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/splitbrain/dokuwiki.git' '/srv/www/wiki' && sudo chown -R 'wwwrun' '/srv/www/wiki' | sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/splitbrain/dokuwiki.git' '/srv/www/wiki' && sudo chown -R 'wwwrun':'www' '/srv/www/wiki' |
| |
sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' '/srv/www/wiki(/.*)?' && sudo restorecon -F -I -R '/srv/www/wiki' | |
| |
====== nginx + PHP-FPM Configuration ====== | ====== nginx + PHP-FPM Configuration ====== |
| |
<code> | <code> |
; php-fpm.d/wiki.conf | |
| |
[wiki] | [wiki] |
| |
| |
===== FastCGI ===== | ===== FastCGI ===== |
| |
| * ''wiki.sock'' |
| |
sudo -e '/etc/nginx/default.d/wiki.conf' | sudo -e '/etc/nginx/default.d/wiki.conf' |
| |
<code> | <code> |
# PHP-FPM | |
| |
location ~ \.(php|phar)(/.*)?$ { | location ~ \.(php|phar)(/.*)?$ { |
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$; | fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$; |
* 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 |
| |
echo '-- --' | sudo tee '/srv/www/wiki/conf/entities.local.conf' > '/dev/null' && sudo chown 'nginx':'nginx' '/srv/www/wiki/conf/entities.local.conf' | echo '-- --' | sudo tee '/srv/www/wiki/conf/entities.local.conf' > '/dev/null' && sudo chown 'wwwrun':'www' '/srv/www/wiki/conf/entities.local.conf' |
| |
====== Services ====== | ====== Services ====== |
<code> | <code> |
[Service] | [Service] |
User=nginx | User=wwwrun |
Group=nginx | Group=www |
Type=oneshot | Type=oneshot |
ExecStart='/usr/bin/git' -C '/srv/www/wiki' pull origin 'master' | ExecStart='/usr/bin/git' -C '/srv/www/wiki' pull origin 'master' |
| |
==== Service ==== | ==== Service ==== |
| |
* :!: The commented ''ExecStart'' would remove page edits older than 90 days | |
| |
sudo -e '/etc/systemd/system/wiki-m.service' | sudo -e '/etc/systemd/system/wiki-m.service' |
<code> | <code> |
[Service] | [Service] |
User=nginx | User=wwwrun |
Group=nginx | Group=www |
Type=oneshot | Type=oneshot |
WorkingDirectory=/srv/www/wiki | WorkingDirectory=/srv/www/wiki |
ExecStart='/usr/bin/git' -C '/srv/www/wiki' gc --aggressive --prune='all' | ExecStart='/usr/bin/git' -C '/srv/www/wiki' gc --aggressive --prune='all' |
ExecStart='/usr/bin/git' -C '/srv/www/wiki' fsck --full --strict | ExecStart='/usr/bin/git' -C '/srv/www/wiki' fsck --full --strict |
#ExecStart='/usr/bin/bash' -c "find '/srv/www/wiki/data'/{attic,cache,locks,media_attic}/ -type 'f' -mtime +'90' -delete" | |
ExecStart='/usr/bin/bash' -c "find '/srv/www/wiki/data'/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp}/ -mindepth '1' -type 'd' -empty -delete" | ExecStart='/usr/bin/bash' -c "find '/srv/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' '/srv/www/wiki/bin/indexer.php' --clear | ExecStart='/usr/bin/php' '/srv/www/wiki/bin/indexer.php' --clear |
===== Backup ===== | ===== Backup ===== |
| |
* This backs up an archive to the local disk and to a NAS | * This backs up an archive to the local disk |
| |
==== Service ==== | ==== 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' | mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/wiki-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/wiki-fb.service' |
WorkingDirectory=/srv/www/wiki | WorkingDirectory=/srv/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 "/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' | ExecStartPost='/usr/bin/sync' |
| |
==== Restore Folders ==== | ==== Restore Folders ==== |
| |
* TODO: ''tar -C'' | * TODO: ''tar -C or --directory='' |
| |
cd '/srv/www/wiki' && sudo tar -xvzf ~/'dokuwiki-files-'*'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sudo restorecon -F -I -R '/srv/www/wiki' && sudo chown -R 'wwwrun' '/srv/www/wiki' && cd ~ && sync | cd '/srv/www/wiki' && sudo tar -xvzf ~/'dokuwiki-files-'*'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sudo chown -R 'wwwrun' '/srv/www/wiki' && cd ~ && sync |
| |
==== Start nginx ==== | ==== Start nginx ==== |