It's better when it's simple

User Tools

Site Tools


DokuWiki on openSUSE

First, it is quite simple to install DokuWiki on openSUSE (or SLES/SLED). Download the tarball from and unpack it into /srv/www/htdocs. Then rename the folder you created by unpacking to dokuwiki and that's nearly all. When you do it on your own PC, you can invoke DokuWiki by entering http://localhost/dokuwiki/install.php (or replace localhost by the name of the host you installed it on) as URL in your browser. The invoked install.php will tell you what is wrong, for example the data dir is not writeable by the web server and so on.

Second, to do all this manually is annoying. So I decided to use openSUSE's build service (see for details) and put DokuWiki into an rpm package that can be installed on all available openSUSE and SLE versions. When you want to install it from there, you may add<your openSUSE version> as installation repository. Unfortunately, it needs apache to run, since this is the only httpd I use myself and where I know how to write the needed config file…

What did I do to create this rpm package?

First, I had to put the DokuWiki files where they belong according to openSUSE's policy (/srv/www/dokuwiki). Then, I had to add an apache configuration file that defines an alias /dokuwiki for this place and contains all the lines from the .htaccess files in the tarball. Downloading, creating the config, and repacking for creation of the rpm is all done by a shell script.

On 2012-11-16 I edited the script so that the config files are now in /etc/DokuWiki, and the conf directory inside the DokuWiki source tree is a symbolic link to the new location.

On 2015-07-02 I edited the script again so that the scripts now stay with “/usr/bin/php” instead of my modification “/usr/bin/php5”. Plus the generated Apache config file contains code for Apache 2.2 and 2.4 now.
# an attempt to automatize packaging DokuWiki for openSUSE
set -x
RELEASE='2015-08-10'      # hey, that's my birthday :)
NEWNAME=$(echo "$RELEASE" | tr '-' '.')
mkdir -p "$WORKDIR/DokuWiki/etc/apache2/conf.d"
mkdir -p "$WWWDIR"
# assume the standard download location
# and get the file
wget -O "${WWWDIR}/DokuWiki.tgz" "${DLFROM}/${DLFILE}"
# unpack it
cd "$WWWDIR" || exit 17
tar -xzf "DokuWiki.tgz"
rm "DokuWiki.tgz"
# move it into the right place, create config dirs
mv "dokuwiki-${RELEASE}" DokuWiki
HTACCESSLIST=$(find "${WWWDIR}/DokuWiki" -name '\.htacc*')
cd "$WORKDIR/DokuWiki/etc" || exit 18
cd "$WWWDIR/DokuWiki"
ln -s "../../..${NEWCONFDIR}" "conf"
# remove executable flags
find "$WWWDIR/DokuWiki" -type f -executable | xargs chmod -x
chmod +x $WWWDIR/DokuWiki/bin/*php
# write config for Apache 2.2 and 2.4
# delete .htaccess, move it into Apache's conf
cd "$WORKDIR/DokuWiki/etc" || exit 15
cat > 'apache2/conf.d/DokuWiki.conf' <<EOT
Alias /dokuwiki "/srv/www/DokuWiki"
<Directory "/srv/www/DokuWiki/">
    Options None
    AllowOverride All
    <IfModule mod_dir.c>
        DirectoryIndex doku.php index.html index.htm
    <IfModule mod_authz_core.c>
      # Apache 2.4
      Require all granted
    <IfModule !mod_authz_core.c>
      # Apache 2.2
      Order allow,deny
      Allow from all
    echo "<Directory \"$RELDIR\">" >> "apache2/conf.d/DokuWiki.conf"
    cat "$SUBDIR"                  >> "apache2/conf.d/DokuWiki.conf"
    echo "</Directory>"            >> "apache2/conf.d/DokuWiki.conf"
    echo " "                       >> "apache2/conf.d/DokuWiki.conf"
    rm "$SUBDIR"
dos2unix -o 'apache2/conf.d/DokuWiki.conf.*'
cd "$WORKDIR" || exit 19
tar --strip-components=$NO_OF_COMP -cf "DokuWiki-${NEWNAME}.tar" DokuWiki
bzip2 "DokuWiki-${NEWNAME}.tar"

Well, that's about all. With a fast internet connection, the script runs in less that a minute for me :-). The resulting file is used by the build process as well as the following spec file:

The 'spec' file

# Spec File for Package DokuWiki
Summary:        A Wiki written in PHP to work without a database
Summary(de):    Ein in PHP geschriebenes Wiki, das keine Datenbank benutzt
Name:           DokuWiki
Version:        2015.08.10
Release:        1%{?dist}
License:        GPL-2.0
Group:          Productivity/Publishing/Other
Distribution:   openSUSE Linux
Vendor:         Andreas Gohr <>
Requires:       apache2-mod_php5
Requires:       php5 >= 5.3
PreReq:         coreutils
PreReq:         apache2
BuildArch:      noarch
Prefix:         /srv/www
Prefix:         /etc
Source:         %{name}-%{version}.tar.bz2
Buildroot:      %{_tmppath}/%{name}-buildroot
DokuWiki is a standards compliant, simple to use Wiki, mainly aimed at creating
documentation of any kind. It is targeted at developer teams, workgroups and small
companies. It has a simple but powerful syntax which makes sure the datafiles
remain readable outside the Wiki and eases the creation of structured texts.
All data is stored in plain text files - no database is required.
Read the DokuWiki Manual to unleash the full power of DokuWiki.
    Andreas Gohr
%description -l de
DokuWiki ist ein einfach zu benutzendes Wiki, mit dem vor allem Dokumentation jeder Art
erstellt werden soll, und dessen Ausgabeformat den Standards entspricht. Zielguppe sind
Entwicklerteams, Arbeitsgruppen und kleine Firmen aller Art. DokuWiki hat eine einfache,
aber mächtige Syntax und erleichtert das Erstellen strukturierter Texte. Alle Daten
werden in reinen Textdateien abgelegt - eine Datenbank ist nicht erforderlich.
Lies das Handbuch von DokuWiki, um seine geballte Kraft freizusetzen.
    Andreas Gohr
%setup -n %{name}
install -d $RPM_BUILD_ROOT/etc/apache2/conf.d/
install -d $RPM_BUILD_ROOT/etc/DokuWiki/
install -d $RPM_BUILD_ROOT/srv/www/DokuWiki/
cp -a etc/* $RPM_BUILD_ROOT/etc/
cp -a srv/www/* $RPM_BUILD_ROOT/srv/www/
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT
%defattr(-, wwwrun, www)
%config /etc/apache2/conf.d/DokuWiki.conf
%config /etc/DokuWiki
%attr (644, root, root) /etc/apache2/conf.d/DokuWiki.conf
%attr (644, wwwrun, www) /etc/DokuWiki/*
%attr (754, wwwrun, www) /srv/www/DokuWiki/bin/dwpage.php
%attr (754, wwwrun, www) /srv/www/DokuWiki/bin/indexer.php
%attr (754, wwwrun, www) /srv/www/DokuWiki/bin/wantedpages.php
%attr (754, wwwrun, www) /srv/www/DokuWiki/inc/phpseclib/
%attr (754, wwwrun, www) /srv/www/DokuWiki/lib/scripts/jquery/

You can use the spec file and the tarball that is produced by the shell script to build DokuWiki locally. Just save the spec file as /usr/src/packages/SPECS/DokuWiki.spec, put the tarball into /usr/src/packages/SOURCES/ and start rpmbuild -ba /usr/src/packages/SPECS/DokuWiki.spec. The resulting rpm will appear in /usr/src/packages/RPMS/noarch/ (plus a source rpm in /usr/src/packages/SRPMS/).

install/opensuse.txt · Last modified: 2015-08-10 13:16 by 2001:4dd0:ff00:9581:552f:20cd:616c:16b3

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki