User Tools

Site Tools


servers:bsd:nginx:dokuwiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
servers:bsd:nginx:dokuwiki [2025/05/16 12:23] Sean Rhoneservers:bsd:nginx:dokuwiki [2025/05/24 05:34] (current) Sean Rhone
Line 1: Line 1:
 +====== Information ======
 +
 +  * DokuWiki ((https://www.dokuwiki.org))
 +  * [[Information:Realm of Espionage]]
 +  * https://wiki.realmofespionage.xyz ((you are here :p))
 +
 +===== Prerequisites =====
 +
 +  * [[bsd:server:freebsd_14.2|FreeBSD 14.2]]
 +  * [[servers:bsd:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]
 +  * [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]]
 +
 +====== Dependencies ======
 +
 +  su -
 +
 +  pkg install git-lite php84-session php84-bz2 php84-filter php84-gd php84-intl php84-mbstring php84-xml php84-zlib
 +
 +====== Download Source ======
 +
 +  * https://github.com/dokuwiki/dokuwiki/commits/master/
 +
 +  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
 +
 +====== nginx + PHP-FPM Configuration ======
 +
 +===== PHP-FPM Socket =====
 +
 +  su -
 +
 +  ee '/usr/local/etc/php-fpm.d/wiki.conf' && service 'php_fpm' restart
 +
 +<code>
 +[wiki]
 +
 +; User/Group
 +user = www
 +group = www
 +
 +; Socket
 +listen = 127.0.0.1:9002
 +listen.allowed_clients = 127.0.0.1
 +
 +; Process Management
 +pm = ondemand
 +pm.max_children = 4
 +pm.process_idle_timeout = 30
 +
 +; General
 +php_value[date.timezone] = "America/New_York"
 +
 +; End</code>
 +
 +===== FastCGI =====
 +
 +  su -
 +
 +  ee '/usr/local/etc/nginx/default.d/wiki.conf'
 +
 +<code>
 +# PHP-FPM
 +location ~ \.(php|phar)(/.*)?$ {
 +    fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
 +    fastcgi_intercept_errors on;
 +    fastcgi_index doku.php;
 +    include fastcgi_params;
 +    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 +    fastcgi_param PATH_INFO $fastcgi_path_info;
 +    fastcgi_param HTTPS on;
 +    fastcgi_pass 127.0.0.1:9002;
 +}
 +
 +# End</code>
 +
 +===== Server Block ======
 +
 +  su -
 +
 +  ee '/usr/local/etc/nginx/vhosts.d/wiki.conf' && service 'nginx' reload && sync
 +
 +<code>
 +server {
 +    listen '443' 'ssl';
 +#    http2 'on';
 +    server_name 'wiki.realmofespionage.xyz';
 +    root '/usr/local/www/wiki';
 +    index 'doku.php';
 +
 +    include '/usr/local/etc/nginx/default.d/wiki.conf';
 +    include '/usr/local/etc/nginx/default.d/headers.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;
 +
 +#    access_log  /var/log/nginx/wiki-access.log;
 +#    error_log  /var/log/nginx/wiki-error.log;
 +
 +#    location = /install.php {
 +#        deny all;
 +#    }
 +
 +#    location ~ /(conf|bin|inc)/ {
 +#        deny all;
 +#    }
 +
 +#    location ~ /data/ {
 +#        internal;
 +#    }
 +
 +    location / { try_files $uri $uri/ @dokuwiki; }
 +
 +    location @dokuwiki {
 +        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
 +        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
 +        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
 +        rewrite ^/(.*) /doku.php?id=$1&$args last;
 +    }
 +}
 +
 +# End</code>
 +
 +====== Initial Setup ======
 +
 +  * https://wiki.realmofespionage.xyz/install.php
 +
 +====== Settings ======
 +
 +===== Plugins =====
 +
 +  * https://www.dokuwiki.org/plugin:searchindex
 +
 +===== Template Style Settings =====
 +
 +  * Alternative background color: ''#484848''
 +  * The general link color: ''#3d8bff''
 +  * :!: The width of the full site: ''100em'' ((this caused some kind of scrollbar I believe on a 1280x800 laptop))
 +
 +===== nginx Server Block Deny Directives =====
 +
 +  * Uncomment commented sections (except logs)
 +  * Do after initial setup
 +
 +  sudo -e '/etc/nginx/vhosts.d/wiki.conf' && sudo systemctl reload 'nginx'
 +
 +===== URL Rewrite =====
 +
 +  * Admin -> Configuration Settings -> DokuWiki -> Advanced -> userewrite
 +
 +  .htaccess
 +
 +===== Double-hyphen Convert Disable =====
 +
 +  * This prevents -- from becoming a – (long hyphen), which breaks some command's syntax
 +
 +  echo '--      --' | sudo tee '/var/www/wiki/conf/entities.local.conf' > '/dev/null' && sudo chown 'nginx':'nginx' '/var/www/wiki/conf/entities.local.conf' && sync
 +
 +====== Temp Commands ======
 +
 +===== Update =====
 +
 +  * https://github.com/dokuwiki/dokuwiki/commits/master/
 +
 +  su -
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' pull origin 'master'"
 +
 +===== Indexer =====
 +
 +  su -
 +
 +  su -m 'www' -c "cd '/usr/local/www/wiki' && '/usr/local/www/wiki/bin/indexer.php' --clear"
 +
 +===== Maintenance =====
 +
 +  su -
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' reset --hard"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' pull origin 'master' --rebase"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' gc --aggressive --prune='all'"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/wiki' fsck --full --strict"
 +
 +====== Backup ======
 +
 +===== Folder =====
 +
 +  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
 +
 +===== scp =====
 +
 +****
 +
 +  scp espionage724@192.168.1.152:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' && sync
 +
 +====== Restore ======
 +
 +===== scp =====
 +
 +****
 +
 +  scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.152:~
 +
 +===== Folder =====
 +
 +  su -
 +
 +  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'
 +
 +  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