Dokuwiki operation life-cycle maintain guide

  1. download dokuwiki at: http://www.dokuwiki.org/dokuwiki
  2. extract the file structure to your Website Wiki folder
  3. start your web server, and browser to the “install.php” in wiki folder; (for me, no permission problem by guide)
  4. Then, create users,
    1. login wiki with your Admin account, click “Admin” button at the right bottom corner;
    2. then, click “User Manager”, create other user for writing and admining in Group of “user” or “admin”
  5. Then, authorize user rights
    1. click “admin” button at the bottom after login as admin
    2. click “Access Control List Management” to define page or namespace (directory) level control
  6. Create page
    1. create page by a internal link: [[techwiki:macfix|Mac Fix tech page]]
    2. create page by entering a new URL: http://mysite/wiki/doku.php?id=techwiki:macfix
  7. delete page
    1. delete page by empty the content of that page
  8. insert media like image and video
    1. use the toolbar in page editing panel

Dokuwiki Upload Image Failed

  • Problem description:
    • when I use XAMPP to setup my local server, and put the dokuwiki in the htdocs folder, I can write wiki page, but upload image just saying “fail”
  • Problem analysis:
    • It can be caused by several things, maybe your folder permission is set wrong, but most likely a fresh copy of dokuwiki folder should have everything set default correctly;
    • It can be caused by your server upload setting, like allow upload in PHP setting, but default XAMPP should have everything setup correctly already
  • Solution:
    1. for my case, I just grab a fresh latest copy of XAMPP from https://sourceforge.net/projects/xampp/files/, the 7z portable version, so I can extract the XAMPP out and put where I want exactly myself
    2. then I run the setup_xampp.bat from the XAMPP folder to tell it where the location it sits
    3. then I just run xampp_control.exe with admin to start the server and mysql properly
    4. put fresh latest copy of dokuwiki in the XAMPP htdocs folder, and browser it from browser, like your machine name and /, following the dokuwiki folder name.
    5. it should all be all right, test by upload a image using dokuwiki image icon

Wiki Folder Permission and Security

  • Problem description
  • Solution
    • when migrating, make sure wiki compressed with file permission info
      cd /path/to/folder/to/copy
      tar cvpzf put_your_name_here.tar.gz .
      
      cd /path/to/destination/folder
      tar xpvzf put_your_name_here.tar.gz
    • after migration, check and fix permission
      • if visit page error, then fix with chmod: fix file permission with chmod
        # check existing htdoc file the_same_user:the_same_group info
        ls -l
        # then for wiki folder, fix own and permission
        # ref: https://www.dokuwiki.org/install:permissions
        cd wiki/
        chmod -R 775 data/
        sudo chown -R the_same_user:the_same_group data/
        cd data/
        chmod 2775 {attic,cache,index,locks,media,meta,pages,tmp}
        chown the_same_user:the_same_group {attic,cache,index,locks,media,meta,pages,tmp}
    • check wiki security by visit a page txt file like ,
      http://your_site.com/wiki/data/pages/subFolder/pageName.txt
      • if accessible, then fix with apache htaccess in httpd.conf (its location vary based on what linux creator you use):
      • put data, conf, bin, inc folder in deny mode, example as for data
        <Directory /web_root_path/wiki/data>
            order allow,deny
            deny from allow
            satisfy all
        </Directory>
        • also prevent file access
          <Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
              Require all denied
          </Files>
  • clean up trash in dokuwiki
    cleanup.sh
    #!/bin/bash
     
    cleanup() {
     
    # $1 ... full path to data directory of wiki
    # $2 ... number of days after which old files are to be removed
     
    # purge files older than $2 days from the attic (old revisions)
    find "$1"/attic/ -type f -mtime +$2 -print0 | xargs -0r rm -f
     
    # remove stale lock files (files which are 1-2 days old)
    find "$1"/locks/ -name '*.lock' -type f -mtime +1 -print0 | xargs -0r rm -f
     
    # remove empty directories
    find "$1"/{attic,cache,index,locks,media,meta,pages,tmp}/ \
    -mindepth 1 -type d -empty -print0 | xargs -0r rmdir
     
    # remove files older than $2 days from the cache
    find "$1"/cache/?/ -type f -mtime +$2 -print0 | xargs -0r rm -f
    }
    # cleanup DokuWiki installations (path to datadir, number of days)
    # some examples:
     
    cleanup /home/user1/htdocs/doku/data    256
    cleanup /home/user2/htdocs/mywiki/data  180
    cleanup /var/www/superwiki/data         180
  • for normal personal or author-free article type wiki, then you just need to backup these 2 folder
    1. /wiki/data/media - this is for images used in wiki
    2. /wiki/data/pages - this is for all the pages
  • for large user base free type wiki, then you may like to backup
    1. /wiki/data/media
    2. /wiki/data/pages
    3. /wiki/data/meta - version and activity tracking;
    • (wiki can re-generate new version tracks if you don't want to keep old ones)
    1. /wiki/data/attic - old things of each edit;
    • (suggest to delete it, or don't backup it if you never undo old changes)
  • for community based tracking type wiki
    • in addition, backup the users and group configuration file and rights configuration
    1. /wiki/conf - wiki configuration and user database
  • not sure what to do
    1. /wiki - backup whole wiki to a zip file
    2. best to tar the wiki folder with permission info as well
      cd /path/to/folder/to/copy
      tar cvpzf put_your_name_here.tar.gz .
      
      cd /path/to/destination/folder
      tar xpvzf put_your_name_here.tar.gz
  • zip the wiki, download, update to new server, extract
  • for server with strict ModSecurity, you need server side whitelist setup to get embeded code part working, and avoid 406 error (ref: https://www.dokuwiki.org/faq:mod_security)
  • run fix date php script to fix external edit and date issue (ref: https://www.dokuwiki.org/tips:fixmtime)
    • Run it from within DokuWiki installation directory.
      <?php 
      /**
       * Fix modification times based on timestamps. Run from within DokuWiki installation directory.
       * @Author: dreamlusion <http://dreamlusion.eucoding.com>
        * last modified: 2008-09-05 4:15:00
       */
      function WalkDirectory($parentDirectory) {
      	global $_weeds;
       
      	foreach(array_diff(scandir($parentDirectory), $_weeds) as $directory)
      	{
      		$path = $parentDirectory . '/'. $directory;
       
      		if(is_dir($path)) 
      		{
      			WalkDirectory($path);
      		}
      		else 
      		{
      			// Calculate changes file path.
      			$path_parts = pathinfo($path);
       
      			// Remove pages path.
      			global $_pagesPath;
      			$relativePath = substr($path_parts['dirname'], strlen($_pagesPath), strlen($path_parts['dirname']));
       
      			// Add <filename>.changes
      			$filename = $path_parts['filename']; // Requires PHP 5.2.0 (http://gr2.php.net/manual/en/function.pathinfo.php)
      			$relativePath .= '/' . $filename . '.' . 'changes';
       
      			global $_metaPath;
      			$changelog = $_metaPath . '/' . $relativePath;
       
      			if (is_file($changelog))
      			{
      				$handle = @fopen($changelog, "r");
      				if ($handle) {
      				    while (!feof($handle)) {
      				        $buffer = fgets($handle);
      				        preg_match('/(?<timestamp>\d+)/', $buffer, $matches);
       
      						if ($matches['timestamp'] != '')
      							$timestamp = $matches['timestamp'];
       
      				    }
      				    fclose($handle);
      				}
       
      				// At this point we have our timestamp.
      				echo 'Updating ' . $path . '<br />';
      				echo '&nbsp;&nbsp;&nbsp;&nbsp;Timestamp in changelog: ' . $timestamp . '<br />';
      				echo '&nbsp;&nbsp;&nbsp;&nbsp;Old modification time: ' . filemtime($path) . '<br />';
      				if (touch($path, $timestamp))
      				{
      					// In my host, although the timestamp had changed successfully (checked manually), running filemtime($path) at this point 
      					// did not return the correct timestamp, so use I use $timestamp instead of filemtime($path) to avoid confusing the user.
      					echo '&nbsp;&nbsp;&nbsp;&nbsp;New modification time: ' . $timestamp . '<br />';
      				}
      				else
      				{
      					echo '&nbsp;&nbsp;&nbsp;&nbsp;Could not change modification time for page ' . $filename;
      				}
      			}
      			else
      			{
      				echo 'Changelog not found: ' . $changelog . '<br />';
      			}
      		}
      	} 
      }
       
      $_weeds = array('.', '..');
      $_pagesPath = getcwd() . '/data/pages';
      $_metaPath = getcwd() . '/data/meta';
       
      WalkDirectory($_pagesPath);
       
      ?>
  • the easiest way to update DokuWiki to latest version is to use “Upgrade” plugin
    1. go to Admin page > plugin manager
    2. check the “Upgrade” plugin from this page, and right click on download to copy the download link url: https://www.dokuwiki.org/plugin:upgrade
    3. paste the url on plugin manager's url text field, and click Download
    4. once finished, in Admin page, there will be a upgrade plugin link, and click it to go through the auto-download-dokuwiki-upgrade system
  • these 2 image shows how to install plugin using plugin manager in admin panel

hide sitemap index from non-login user

  • check on Configuration Manager > sneaky_index

change wiki page width

  • method 0 - Toggle Page Width with Javascript, CSS and Side Tool customize on “/lib/tpl/dokuwiki/main.php”
    1. step 1: edit main.php head part to add css and javascript function (jquery no need)
      <style>
      .fullpageOn{
          max-width: 100% !important;
      }
      </style>
      <script>
      // standard javascript here
      function toggleFullPage() {
        var myPageClasses = document.getElementById("dokuwiki__site").classList;
        if (myPageClasses.contains("fullpageOn")) {
          myPageClasses.remove("fullpageOn");
        } else {
          myPageClasses.add("fullpageOn");
        }
      }
      </script>
    2. step 2: edit main.php page action part
      <!-- under PAGE ACTIONS -->
      <!-- just above the last </ul> tag -->
      <li><a href="#" onclick="toggleFullPage()" class="action" accesskey="w" rel="nofollow" title="Full Page Width [w]"><span>Full Page Width</span></a></li>
  • method 1 with css:
    /* find css file in default template folder with class dokuwiki__site
    #dokuwiki__site {
        max-width: 100% !important;
    } 
  • method 2 with style.ini in default template folder (ref)
    __site_width__      = "100%"            ; @ini_site_width
    #defaut
    __site_width__      = "75em"            ; @ini_site_width

change “doku.php” in URL (you need repeat steps if you update dokuwiki)

  1. change the file name “wiki/doku.php” into “wiki/newName.php” (such as “page.php”; but can not be “index.php”, as it is reserved for default)
  2. edit wiki/index.php part
    header("Location: newName.php");
  3. create wiki/inc/preload.php
    if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','newName.php');

change wiki URL format

change 2013 or later DokuWiki homepage logo (further if you want to change the favicon)

  • method 1: use media manager, under wiki namespace, upload new logo to replace old one (:wiki:logo.png). (ref)
  • method 2: go dokuwiki\lib\tpl\dokuwiki\images, swap out the image with your same correct size one
    • apple-touch-icon.png
    • favicon.ico
    • logo.png

DokuWiki Favicon

  • generate favicon from logo: http://www.favicon-generator.org/
  • loading priority sequence
    1. $DokuWiki/data/media/favicon.ico
    2. $DokuWiki/lib/tpl/dokuwiki/images/favicon.ico
    3. $DokuWiki root/favicon.ico
    4. web root/favicon.ico

change 2013 or later DokuWiki theme, top “Media Manager” link for non-user (repeat after each update)

  • need to edit lib/tpl/dokuwiki/tpl_header.php file
  • then in the display “Media Manager” link part, add a user login condition check
    tpl_action('recent', 1, 'li');
    if(!empty($INFO['userinfo']['name'])){
    tpl_action('media', 1, 'li'); 
    tpl_action('index', 1, 'li'); 
    }
    // note: $INFO['client'] will give ip or username
    // ref: $INFO variable in dokuwiki: https://www.dokuwiki.org/devel:environment
  • for new wiki check this
    # change
    tpl_toolsevent('sitetools', array(
        tpl_action('recent', true, 'li', true),
        tpl_action('media', true, 'li', true),
        tpl_action('index', true, 'li', true)
    ));
    # into 
    if(!empty($INFO['userinfo']['name'])){
        tpl_toolsevent('sitetools', array(
            tpl_action('recent', true, 'li', true),
            tpl_action('media', true, 'li', true),
            tpl_action('index', true, 'li', true)
        ));
    }
    else{
        tpl_toolsevent('sitetools', array(
           tpl_action('recent', true, 'li', true)
       ));
    }

Basic Syntax

no way but plugin

name then size

{{wiki:dokuwiki-128.png?20x50}}
  • Use [[dir_name_space:pageName|Link_Text]] to create internal link;
  • Just type link as http://google.com to create normal link;
  • Use [[http://google.com|Google]] to create title link like Google
  • Use [[this>./subCustomFolder/myfile.mp4|Video]] to link a relative path from wiki root

"2 spaces followed by * or -" at line start will create unordered or ordered list;
“2 extra spaces” in front will indent it to sub-level.

There are 4 ways to create a line break, or a blank line.

  • type “2 Enter key” to create 1 blank line
  • type “\\” to create <br> like link break
  • type "%% content %%" to create line-keep-as-you-type block
  • type "<nowiki> content </nowiki>" to create line-keep-as-you-type block
  • four “-” and more makes a Separator line, like below

type "<code language> content </code>" to create code like block

Plain code text here


type "<file language fileName.txt> content </file>" to create downloadable code

fileName.txt
Plain code text here

Supported:
4cs, abap, actionscript-french, actionscript, actionscript3, ada, apache, applescript, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, ecmascript, eiffel, email, erlang, fo, fortran, freebasic, fsharp, gambas, genero, genie, gdb, glsl, gml, gnuplot, groovy, gettext, gwbasic, haskell, hicest, hq9plus, html, icon, idl, ini, inno, intercal, io, j, java5, java, javascript, jquery, kixtart, klonec, klonecpp, latex, lisp, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, modula2, modula3, mmix, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, ocaml-brief, ocaml, oobas, oracle8, oracle11, oxygene, oz, pascal, pcre, perl, perl6, per, pf, php-brief, php, pike, pic16, pixelbender, plsql, postgresql, povray, powerbuilder, powershell, progress, prolog, properties, providex, purebasic, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, vala, vbnet, vb, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, winbatch, whois, xbasic, xml, xorg_conf, xpp, z80

  • :sidebar for sidebar content

Dokuwiki user group setup and security control

Method:

  1. use dokuwiki admin page control
  2. use text config of dokuwiki: official guide

DokuWiki Preference Configure

  • /wiki/conf/dokuwiki.php
    $conf['start'] = 'Welcome';           //name of start page

DokuWiki plugins

DokuWiki Theme and Customize