Description

Dokuwiki is a good small platform for content management which achieves great performances under lighttpd. On a jailbroken iDevice, we install lighttpd and dokuwiki and tweak them to make them work as fast as possible.

lighttpd

First, you need to install lighttpd from cydia. After that, create the file /etc/lighttpd.conf with the following contents:

lighttpd.conf
server.document-root = "/var/www/"
index-file.names = ( "index.php" )
 
server.max-keep-alive-requests = 2
server.max-keep-alive-idle = 2
server.stat-cache-engine = "simple"
server.network-backend = "writev"
server.use-noatime = "enable"
server.max-stat-threads  = 2
server.max-read-threads = 3
 
server.modules = (
 "mod_fastcgi",
 "mod_rewrite",
)
 
fastcgi.server = ( ".php" =>
 ( "localhost" =>
   (
     "socket" => "/tmp/php-fastcgi.socket",
     "bin-path" => "/usr/bin/php-cgi",
     "min-procs" => 1,
     "max-procs" => 2,
     "max-load-per-proc" => 4, 
     "idle-timeout" => 25,
     # Fix PATH_INFO for PHP scripts that rely on it (like Wordpress).
     "broken-scriptfilename" => "enable",
     "allow-x-send-file" => "enable" # Enables x-sendfile
    )
   )
 )
 
# rewrites for dokuwiki
$HTTP["url"] =~ "^" { index-file.names = ("doku.php") }
    url.rewrite = (
      "^/lib/.*$"              => "$0",
      "^/_media/(.*)?\?(.*)$"  => "/lib/exe/fetch.php?media=$1&$2",
      "^/_media/(.*)$"         => "/lib/exe/fetch.php?media=$1",
      "^/_detail/(.*)?\?(.*)$" => "/lib/exe/detail.php?media=$1&$2",
      "^/_detail/(.*)?$"       => "/lib/exe/detail.php?media=$1",
      "^/_export/([^/]+)/(.*)\?(.*)$" => "/doku.php?do=export_$1&id=$2&$3",
      "^/_export/([^/]+)/(.*)" => "/doku.php?do=export_$1&id=$2",
      "^/doku.php.*"           => "$0",
      "^/feed.php.*"           => "$0",
      "^/(.*)\?(.*)"           => "/doku.php?id=$1&$2",
      "^/(.*)"                 => "/doku.php?id=$1"
    )
 
mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
 )

In this case, we will be running dokuwiki with the document root at /var/www under no subdirectory. That is, you would access your wiki using:

http://IDEVICE_IP/

and the start page should show up.

PHP

Next, install PHP from Cydia and create the file /usr/lib/php.ini (not the standard /etc/php.ini) with the following configuration settings:

php.ini
memory_limit = 16M
asp_tags = Off
register_argc_argv = Off
register_globals = Off
expose_php = Off
register_long_arrays = Off
always_populate_raw_post_data = Off
realpath_cache_size = 16K
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
zlib.output_compression = On
zlib.output_compression_level = 6

which are more or less optimizations meant to turn off unnecessary options as well as enabling compression.

Dokuwiki

Next, install the ImageMagick package from Cydia. We will use ImageMagick because libgd is unavailable under the iOS PHP compiled by saurik.

Whether you want to transfer over a wiki to your iDevice or are setting a new one up, the following configuration settings are specific for running dokuwiki on your iDevice:

$conf['im_convert'] = '/usr/bin/convert'; // uses imagemagick instead of libgd
$conf['userewrite'] = '1'; // lets lighttpd handle the rewrites, more elegant than dokuwiki rewrites
$conf['compression'] = 'bz2'; // uses bz2 compression
$conf['xsendfile'] = '1'; // uses lighttpd <= 1.4 x-sendfile

Starting

To start lighttpd, you can ssh to the iDevice and issue the following command:

lighttpd-angel -f /etc/lighttpd.conf

which will load the /etc/lighttpd.conf configuration file from the previous section.

Alternatively, you can create a plist which will launch the lighttpd daemon on boot. In order to do that create the file /Library/LaunchDaemons/net.lighttpd.plist with the following contents:

net.lighttpd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>net.lighttpd</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/lighttpd</string>
		<string>-D</string>
		<string>-f</string>
		<string>/etc/lighttpd.conf</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

and load the plist with:

launchctl load -w /Library/LaunchDaemons/net.lighttpd.plist

Extras

A nice additional feature would be to install the dokuwiki sync plugin in order to sync with a wiki on your web-server. Briefly, you have to install the dokuwiki sync plugin through the plugin-manager and then configure both wikis to accept XMLRPC requests. You can do so by going to Admin and enabling the XMLRPC option and specifying a user that is allowed to sync the wikis.


ios/dokuwiki.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.