====== Why DokuWiki? ======
[[doku>dokuwiki]] is a free PHP-based [[wp>wiki]] aimed at technical documentation (hence its employment here!). As the ReadyNAS is already running the [[wp>Apache]] web-server its sensible to use it to serve up your DokuWiki pages too. Personally I installed DokuWiki on my [[linksys:nslu2]] and have got used to using it, its simple, yet feature rich (there are lots of [[doku>plugins]]).
This guide relies heavily on the official ReadyNAS [[http://www.readynas.com/?p=140|Setting up a PHP CGI Environment]] and [[http://www.readynas.com/?p=135|Create a personal webserver on the ReadyNAS]] HowTo's with some additional information on installing and getting [[doku>dokuwiki]].
===== Install PHP & CGI environment =====
This is a pre-requisite to installing [[readynas:dokuwiki|DokuWiki]] as DokuWiki is written in [[wp>PHP]] and requires [[wp>CGI]]. The instructions are provided in the [[http://www.readynas.com/?p=140|ReadyNAS Developers Centre]], and follow naturally from having installed ''apt-get'', you only need to install one [[wp>Apache]] module for php
- Ssh to your ReadyNAS and as ''root'' install ''libapache2-mod-php5'' with:
ReadyNAS:~/# apt-get install libapache2-mod-php5
- Ensure that ''/etc/frontview/apache/httpd.conf'' Apache configuration file has ''index.php'' listed under ''DirectoryIndex'' :
ReadyNAS:~/# grep 'index\.php' /etc/frontview/apache/httpd.conf
DirectoryIndex redirect.html index.html index.htm index.php
- If this is missing (it wasn't when I did this) use ''nano'' to edit the file and add ''index.php'' to the end of the line (''nano -w /etc/frontview/apache/httpd.conf'').
- Restart the Apache server (I diverge from the official documentation here, instead preferring to use the system ''init'' script that is designed for starting/stopping/restarting services):
ReadyNAS:~/# /etc/init.d/apache2 restart
===== Setup a Web-share =====
- Go to the Frontview page for your ReadyNAS and navigate to Shares -> Share Listing.
- Click on the "Add Shares" tab and create a share called ''dokuwiki'' with the description ''Dokuwiki site'' and leave the "Public Access" tick box ticked.
- Click on "Apply" at the bottom of the page.
- Now go back to the "Share List" tab and on any of the icons in the ''dokuwiki'' row to change the permissions on this directory.
- Change the Default Access for HTTP/S to 'Read only', and make sure CIFS/NFS/Rsync are all disabled.
- Now navigate to 'Services -> Standard File Protocols' and under the HTTP section select "dokuwiki" from the pulldown menu to 'Redirect default web access to this share' and hit "Apply".
===== Install DokuWiki =====
We're now ready to install DokuWiki itself. It will be installed to the 'dokuwiki' share that we just created but directly rather than through the Share interface.
- Ssh to your ReadyNAS and ''su'' to root.
- Change directory to the Dokuwiki share (''cd /c/dokuwiki'')
- Obtain the latest [[http://www.splitbrain.org/projects/dokuwiki|DokuWiki source]] using ''wget''...:
ReadyNAS:/c/dokuwiki# wget http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-2010-11-07.tgz
- Extract the files to the current directory:
ReadyNAS:/c/dokuwiki# tar xzvf dokwiki-2010-11-07.tgz -C .
- Set the file and folder permissions on everything that has just been extracted to match those of the ''/c/dokuwiki/'' directory itself.:
ReadyNAS:~/# cd /c/
ReadyNAS:/c/# chown -R admin:admin dokuwiki
- Point your browser at the ''install.php'' file in the DokuWiki share, this will be something like [[http://readynas/dokuwiki/install.php]] or if you've not set a [[wp>Hostname|hostname]] for your ReadyNAS it will include the IP address of the device on your network such as [[http://192.168.1.101/dokuwiki/install.php]].
- Follow the instructions and you should have a working [[doku>install|DokuWiki install]].
==== Migrating DokuWiki ====
I already had a fairly well used DokuWiki installed on my [[linksys:nslu2|NSLU2]] that I wanted to migrate over to the ReadyNAS. Thankfully because DokuWiki is essentially based around simple text file pages this was fairly straight-forward. After setting the file and folder permissions above, instead of pointing your browser to ''install.php''...
- Go to your pre-existing DokuWiki install and compress the ''data/'' and ''lib/plugins/'' sub-directories (which contains all of the pages you have written and your plugins). Something like:
host:~/# cd /opt/share/www/dokuwiki
host:/opt/share/www/dokuwiki/# tar cjvf dokuwiki_data_plugin.tar.bz2 data/ lib/plugins/
- Copy this archive over to the ReadyNAS and into ''/c/dokuwiki/'' directory (**NB - this is done as ''admin''**)...:
host:/opt/share/www/dokuwiki/# scp dokuwiki_data_plugin.tar.bz2 admin@readynas:/c/dokuwiki/.
- ssh to your ReadyNAS, ''cd /c/dokuwiki/'' and extract the data files and set the ownership of the data directory:
ReadyNAS:~/# cd /c/dokuwiki/
ReadyNAS:/c/dokuwiki# tar xjvf dokuwiki_data_plugin.tar.bz2
ReadyNAS:/c/dokuwiki# cd ../
ReadyNAS:/c/dokuwiki# chown -R admin:admin dokuwiki
- Now point your browser at the install.php file in the DokuWiki share, this will be something like http://readynas/dokuwiki/install.php or if you've not set a hostname for your ReadyNAS it will include the IP address of the device on your network such as http://192.168.1.101/dokuwiki/install.php.
- Follow the instructions and you should have a working DokuWiki install.
You should now be able to point your browser at ''http://readynas/dokuwiki/'' or whatever its IP address is on the local network and see your wiki hosted on your ReadyNAS. Thats great if you're only ever going to view/edit your wiki at home, but really you'd like to access it from anywhere in the world wouldn't you?
===== Configure your Routers Port-forwarding =====
If you want to be able to access your Wiki from anywhere on the internet you will have to setup your router to forward requests on port 80 (the default port on which http access is provided) to the ReadyNAS.
==== Background ====
Your [[wp>Internet_service_provider|ISP]] provides your internet connection, and every device connected to the internet has an [[wp>IP_address|IP address]] which uniquely identifies them. These are numeric id's such as ''272.146.13.158'' and can be a little awkward to remember.
==== DynamicDNS ====
Thankfully someone came up with the idea of [[wp>Domain_Name_System|Domain Name System]] which allows more easy-to-remember web-address' like ''www.google.co.uk'' to be mapped to the IP address, so you don't have to worry about remembering the numeric IP address, but can instead remember the text description. To save you having to remember your IP address all the time (and it can change over time when your ISP assigns you a new one) you can use DynamicDNS from somewhere like [[http://www.no-ip.org/|No-IP.org]] to assign an web-address to your IP address (and update it if you get assigned a new IP address by your ISP). So [[http://www.whatismyipaddress.com|look up your ISP assigned IP address]] and go and choose a domain name at [[http://www.no-ip.org/|No-IP.org]].
==== Configure your Router ====
I couldn't possibly guess what router you have, but you will want to configure it to forward Port 80 to the IP address your NAS is assigned on your local network. The [[http://www.readynas.com/forum/faq.php#How_can_I_setup_port-forwarding_to_the_ReadyNAS%3F|official ReadyNAS FAQ on port-forwarding]] points you to an article on [[http://portforward.com/english/routers/port_forwarding/routerindex.htm|Router Port Forwarding]] and I'm going to do the same.
Once you've registered a domain name and setup port-forwarding you should now be able to access your Dokuwiki hosted on your ReadyNAS by simply pointing a browser at the domain name you registered.
===== Upgrading =====
Once installed and running you will, when logged into Dokuwiki as an administrator, notice occasionally that there are notifications telling you that updates are available. Its wise to install these as they often fix bugs and security issues. Thankfully its pretty easy to do. Official instructions are [[doku>install:upgrade|here]], but I've written my own walk through (heavily based on these).
* SSH to your ReadyNAS, ''su'' to root and ''cd /c/dokuwiki''.
* Backup your data...
cp -a /c/dokuwiki /tmp/.
* Grab the source for the latest upgrade (modify this to reflect whatever the [[http://www.splitbrain.org/projects/dokuwiki|latest version available]] is)...
cd tmp
wget http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-rc2011-11-10.tgz
* Extract the contents and copy them over the install...
tar xzvf dokuwiki-rc2011-11-10.tgz
'cp' dokuwiki-rc2011-11-10/{*,.??*} /c/dokuwiki/.
* Remove ''install.php'' and change the permissions on the ''data/'' directory...
cd /c/dokuwiki
rm install.php
cd /c/dokuwiki/data
chown -R admin:admin
* Remove old files that are no longer needed (see list [[http://www.dokuwiki.org/install:upgrade#files_to_remove|here]])...
Thats pretty much it, there are a few additional things to check detailed in the [[http://www.dokuwiki.org/install:upgrade|official upgrade instructions]] that you should check though.
===== Recommendations =====
I'd recommend that you use [[doku>namespaces]] from the outset on your DokuWiki as it helps keep things tidier.
===== Links =====
* [[http://www.readynas.com/?p=135|Create a personal webserver on the ReadyNAS]]
* [[http://portforward.com/english/routers/port_forwarding/routerindex.htm|Router Port Forwarding]]
* [[doku>install|DokuWiki Installation]]
{{tag> readynas php dokuwiki howto}}