| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| servers:linux:nginx:dokuwiki [2026/04/30 22:21] – Sean Rhone | servers:linux:nginx:dokuwiki [2026/07/10 20:54] (current) – [Server Block] Sean Rhone |
|---|
| ===== Prerequisites ===== | ===== Prerequisites ===== |
| |
| * [[linux:distros:server:opensuse_tumbleweed_server|openSUSE Tumbleweed (Server)]] | * [[linux:distros:server:arm:opensuse_tumbleweed_server|openSUSE Tumbleweed (Server)]] |
| * [[servers:linux:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] | * [[servers:linux:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] |
| * [[servers:linux:nginx:lets_encrypt|Certbot (Let's Encrypt)]] | * [[servers:linux:nginx:lets_encrypt|Certbot (Let's Encrypt)]] |
| * https://github.com/dokuwiki/dokuwiki/blob/master/composer.json | * https://github.com/dokuwiki/dokuwiki/blob/master/composer.json |
| |
| sudo zypper install php8-bz2 php8-gd php8-intl php8-mbstring php8-sodium php8-zlib | sudo zypper install php8-bz2 php8-gd php8-intl php8-mbstring php8-openssl php8-sodium php8-zlib |
| |
| ====== Download Source ====== | ====== Download Source ====== |
| <code> | <code> |
| [wiki] | [wiki] |
| listen = "/run/php-fpm/wiki.sock" | |
| |
| user = "wwwrun" | user = "wwwrun" |
| group = "www" | group = "www" |
| | |
| | listen = "/run/php-fpm/wiki.sock" |
| listen.owner = "wwwrun" | listen.owner = "wwwrun" |
| listen.group = "www" | listen.group = "www" |
| pm.process_idle_timeout = "30" | pm.process_idle_timeout = "30" |
| |
| php_value[log_errors] = "Off" | php_value[log_errors] = "0" |
| php_value[error_reporting] = "~E_ALL" | php_value[error_reporting] = "~E_ALL" |
| php_value[display_errors] = "Off" | php_value[display_errors] = "0" |
| php_value[display_startup_errors] = "Off" | php_value[display_startup_errors] = "0" |
| php_value[html_errors] = "Off" | php_value[html_errors] = "0" |
| |
| php_value[session.save_path] = "/var/lib/php8/sessions" | php_value[session.save_path] = "/var/lib/php8/sessions" |
| |
| <code> | <code> |
| location '~' '\.(php|phar)(/.*)?$' { | location '~' '\.(php|phar)(/.*)?$' { |
| fastcgi_split_path_info '^(.+\.(?:php|phar))(/.*)$'; | fastcgi_split_path_info '^(.+\.(?:php|phar))(/.*)$'; |
| fastcgi_intercept_errors 'on'; | fastcgi_intercept_errors 'on'; |
| fastcgi_index 'doku.php'; | fastcgi_index 'doku.php'; |
| include 'fastcgi_params'; | include 'fastcgi_params'; |
| fastcgi_param 'SCRIPT_FILENAME' '$document_root$fastcgi_script_name'; | fastcgi_param 'SCRIPT_FILENAME' '$document_root$fastcgi_script_name'; |
| fastcgi_param 'PATH_INFO' '$fastcgi_path_info'; | fastcgi_param 'PATH_INFO' '$fastcgi_path_info'; |
| fastcgi_param 'HTTPS' 'on'; | fastcgi_param 'HTTPS' 'on'; |
| fastcgi_pass 'unix:/run/php-fpm/wiki.sock'; | fastcgi_pass 'unix:/run/php-fpm/wiki.sock'; |
| } | } |
| | |
| | # End</code> |
| | |
| | ===== Deny Directives ===== |
| | |
| | * https://www.dokuwiki.org/security#web_access_security |
| | |
| | sudo -e '/etc/nginx/default.d/dokuwiki-deny.conf' |
| | |
| | <code> |
| | # Web Access Security |
| | location = '/install.php' { |
| | deny 'all'; |
| | } |
| | |
| | location '~' '/(conf|bin|inc)/' { |
| | deny 'all'; |
| | } |
| | |
| | location '~' '/data/' { |
| | internal; |
| | } |
| |
| # End</code> | # End</code> |
| include '/etc/nginx/default.d/wiki.conf'; | include '/etc/nginx/default.d/wiki.conf'; |
| include '/etc/nginx/default.d/headers.conf'; | include '/etc/nginx/default.d/headers.conf'; |
| | # include '/etc/nginx/default.d/dokuwiki-deny.conf'; |
| client_max_body_size '10M'; | |
| |
| add_header 'Content-Security-Policy' "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" 'always'; | add_header 'Content-Security-Policy' "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" 'always'; |
| # access_log '/var/log/nginx/wiki-access.log'; | # access_log '/var/log/nginx/wiki-access.log'; |
| # error_log '/var/log/nginx/wiki-error.log'; | # error_log '/var/log/nginx/wiki-error.log'; |
| |
| # location = '/install.php' { | |
| # deny 'all'; | |
| # } | |
| |
| # location '~' '/(conf|bin|inc)/' { | |
| # deny 'all'; | |
| # } | |
| |
| # location '~' '/data/' { | |
| # internal; | |
| # } | |
| |
| location '/' { | location '/' { |
| * The width of the full site: ''85%'' | * The width of the full site: ''85%'' |
| |
| ===== nginx Server Block Deny Directives ===== | ===== nginx Deny Directive ===== |
| |
| * Uncomment commented sections (except logs) | * Uncomment ''dokuwiki-deny.conf'' include |
| * Do after initial setup | * Do after initial setup |
| |
| ==== Service ==== | ==== Service ==== |
| |
| * TODO: [[linux:notes:ext4]] | * [[linux:notes:ext4|ext4 NAS]] |
| |
| 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=/tmp | WorkingDirectory=/tmp |
| |
| ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/dokuwiki-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/www/wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"' | ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/mnt/NAS1/Servers/Scheduled Backups/dokuwiki-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/www/wiki" "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" -C "/srv/www/wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"' |
| |
| # End</code> | # End</code> |
| |
| ===== Files ===== | ===== Files ===== |
| |
| **** | |
| |
| sudo tar -czf ~/'dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/srv/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' | sudo tar -czf ~/'dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/srv/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' |
| |
| ===== scp ===== | ===== scp ===== |
| |
| **** | |
| |
| scp espionage724@192.168.1.152:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' | scp espionage724@192.168.1.152:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' |
| |
| ===== scp ===== | ===== scp ===== |
| |
| **** | |
| |
| scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.152:~ | scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.152:~ |
| |
| ===== Stop nginx ===== | ===== Stop nginx ===== |
| |
| **** | |
| |
| sudo systemctl stop 'nginx' | sudo systemctl stop 'nginx' |
| |
| ===== Remove Existing Files ===== | ===== Remove Existing Files ===== |
| |
| **** | |
| |
| ls ~/'dokuwiki-files-'*'.tar.gz' && sudo rm -Rf '/srv/www/wiki/data/pages' '/srv/www/wiki/data/meta' '/srv/www/wiki/data/media' '/srv/www/wiki/data/media_meta' '/srv/www/wiki/data/attic' '/srv/www/wiki/data/media_attic' '/srv/www/wiki/conf' | ls ~/'dokuwiki-files-'*'.tar.gz' && sudo rm -Rf '/srv/www/wiki/data/pages' '/srv/www/wiki/data/meta' '/srv/www/wiki/data/media' '/srv/www/wiki/data/media_meta' '/srv/www/wiki/data/attic' '/srv/www/wiki/data/media_attic' '/srv/www/wiki/conf' |
| |
| ===== Restore Files ===== | ===== Restore Files ===== |
| |
| **** | |
| |
| sudo tar -xzf ~/'dokuwiki-files-'*'.tar.gz' -C '/srv/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sudo chown -R 'wwwrun':'www' '/srv/www/wiki' && sudo chmod -R '0755' '/srv/www/wiki' | sudo tar -xzf ~/'dokuwiki-files-'*'.tar.gz' -C '/srv/www/wiki' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sudo chown -R 'wwwrun':'www' '/srv/www/wiki' && sudo chmod -R '0755' '/srv/www/wiki' |
| sudo su 'wwwrun' -s '/bin/bash' | sudo su 'wwwrun' -s '/bin/bash' |
| |
| cd '/srv/www/wiki' && '/usr/bin/php' '/srv/www/wiki/bin/indexer.php' --clear | cd '/tmp' && '/usr/bin/php' '/srv/www/wiki/bin/indexer.php' --clear |
| |
| exit | exit |
| |
| ===== Start nginx ===== | ===== Start nginx ===== |
| |
| **** | |
| |
| sudo systemctl start 'nginx' | sudo systemctl start 'nginx' |
| |
| ===== Clean-up ===== | ===== Clean-up ===== |
| |
| **** | |
| |
| rm -fv ~/'dokuwiki-files-'*'.tar.gz' | rm -fv ~/'dokuwiki-files-'*'.tar.gz' |
| ====== TODOs ====== | ====== TODOs ====== |
| |
| * https://www.dokuwiki.org/cli?s%5B%5D=wantedpages.php | ===== Find Orphaned Pages ===== |
| * https://www.dokuwiki.org/rewrite | |
| | * https://www.dokuwiki.org/cli#wantedpagesphp |
| | |
| | sudo su 'wwwrun' -s '/bin/bash' |
| | |
| | cd '/tmp' && '/usr/bin/php' '/srv/www/wiki/bin/wantedpages.php' |
| | |
| | cd '/tmp' && '/usr/bin/php' '/srv/www/wiki/bin/wantedpages.php' --help |
| | |
| | exit |
| |