Skip to main content

DokuWiki - Instalace, Konfigurace

Návod pro instalaci a konfiguraci DokuWiki pro Debian GNU/Linux s využitím Apache web serveru. Návod čerpá z oficiálního návodu.

Systém

  • Nainstalovat závislosti:
    apt update
    apt install php libapache2-mod-php php-xml php-json php-mbstring php-zip php-intl php-gd php-sqlite3
    

Apache

  • Aktivovat Apache moduly:
    a2enmod rewrite
    a2enmod headers
    

Instalace

Jelikož je DokuWiki úplně statická, řešíme jen jak dostat software na server a vystavit jej do sítě.

Apache

  1. Přepsat výchozí konfigurační soubor Apache. Používám letsencrypt, pokud by to mělo být jinde, je potřeba upravit.

    FQDN_SERVERU=dokuwiki.cvut.it
    ADMIN_MAIL=lmaoman@cvut.it
    cat > /etc/apache2/sites-available/000-default.conf << EOL
    <VirtualHost *:443>
    
       ### Base settings
       ServerAdmin $ADMIN_MAIL
       DocumentRoot /srv/http/dokuwiki
    
       # Prevent access to data directories
       <Directory /srv/http/dokuwiki/data>
           Require all denied
       </Directory>
    
       <Directory /srv/http/dokuwiki/conf>
           Require all denied
       </Directory>
    
       <Directory /srv/http/dokuwiki/bin>
           Require all denied
       </Directory>
    
       # Allow access to the main directory
       <Directory /srv/http/dokuwiki>
          Options -Indexes +FollowSymLinks
          AllowOverride All
          Require all granted
       </Directory>
    
       ## SSL
       ServerName balonluk.fit.cvut.cz
       Include /etc/letsencrypt/options-ssl-apache.conf
    
       ## Log
       # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
       # error, crit, alert, emerg.
       # It is also possible to configure the loglevel for particular
       # modules, e.g.
       #LogLevel info ssl:warn
    
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
    
       # allow .htaccess 
       <Directory /srv/http/dokuwiki>
           AllowOverride All
       </Directory>
    
       ### Location settings
       <Location />
           SSLRequireSSL
           SSLOptions +StdEnvVars
    
           Options Indexes Includes FollowSymLinks
           AllowOverride AuthConfig Limit
           Order allow,deny
           Allow from all
       </Location>
    
       SSLCertificateFile /etc/letsencrypt/live/$FQDN_SERVERU/fullchain.pem
       SSLCertificateKeyFile /etc/letsencrypt/live/$FQDN_SERVERU/privkey.pem
    </VirtualHost>
    EOL
    
    
  2. Otestovat, že je konfigurace v pořádku:

    apachectl configtest
    
  3. Restartovat webserver:

    systemctl restart apache2
    

DokuWiki

  1. Vytvořit si složky pro hosting, třeba /srv/http/dokuwiki
    mkdir -p /srv/http/dokuwiki
    
  2. Stáhnout zdroj a rozbalit:
    cd /srv/http/dokuwiki
    wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
    tar xzvf dokuwiki-stable.tgz --strip-components=1 && \
    rm -fv dokuwiki-stable.tgz
    
  3. Otevřít adresu webserveru s postfixem install.php, takže např: https://dokuwiki.cvut.it/install.php a dokončit instalaci DokuWiki.

Hotovo 🙂‍↔️

Konfigurace

Poskytovatel identit

OpenID Connect

Entra ID

🗒️ V tomto návodu používáme plugin oauthazure který pro svou funkčnost vyžaduje plugin:oauth.

Jak nastavíme OIDC pomocí vlastní Entra ID ?

  • EntraID

    • Vytvořit App registration.
    • Authentication => [ + Add a platform ] => Web => Nastavit Redirect URI na https://$FQDN/doku.php. Například: https://dokuwiki.cvut.it/doku.php
    • Certificates & secrets => [ + New client secret ] => < Pojmenovat si klíč a nastavit platnost (volil bych nejdelší - 24 měsíců) > => [Add]. Zkopírovat HODNOTU (Value), nikoliv Secret ID a uložit si jej někam (později jej budeme potřebovat).
    • Token configuration => [ + Add groups claim ] => Customize token properties by type =>
      • [X] Security groups
      • [ ] Directory roles
      • [ ] All groups (includes 3 group types: security groups, directory roles, and distribution lists)
      • [ ] Groups assigned to the application (recommended for large enterprise companies to avoid exceeding the limit on the number of groups a token can emit)
      • Customize token properties by type:
        • ID:
          • sAMAccountName
    • API permissions
      • [ + Add a permission ] => Microsoft Graph => Delegated permissions =>
        • OpenId permissions

          🗒️ User.Read => Allows users to sign-in to the app, and allows the app to read the profile of signed-in users. It also allows the app to read basic company information of signed-in users.
          GroupMember.Read.All => Allows the app to list groups, read basic group properties and read membership of all groups the signed-in user has access to.

          • email (Plugin vyžaduje i User.Read)
          • openid (Plugin vyžaduje i User.Read)
          • profile (Plugin vyžaduje i User.Read)
          • GroupMember.Read.All
        • => [ Add permissions ]
        • Kliknout na [ Grand admin consent for <jméno tvého tenantu> ]. Toto je nutné pro scope GroupMember.Read.All, u ostatních jde vybrat Revoke admin consent.

          🗒️ Tato akce udělí všem uživatelům oprávnění používat tento scope v této aplikaci.

  • DokuWiki

    1. Přejít na Admin > Extension manager > Search & Install (https://$FQDN/doku.php?id=wiki:welcome&do=admin&page=extension&tab=search&q=)
    2. Vyhledat oauth
    3. Nainstalovat oauth plugin a oAuth Azure Service
    4. Přejít na Admin > Configuration settings (https://$FQDN/doku.php?id=wiki:welcome&do=admin&page=config)
      • V sekci Authentication nastavit authtype na oauth
      • V sekci Oauth:
        • Pokud používáme reverzní proxy nastavit plugin»oauth»custom-redirectURI na veřejnou URI wikiny následované suffixem doku.php (https://$FQDN/doku.php)
    • V sekci Oauthazure:
      • plugin»oauthazure»key => Client ID: Application (client) ID
      • plugin»oauthazure»secret => Client Secret: <Ve třetím bodu EntraID u Certificates & secrets jsme si vytvořili secret, vložit sem>

        💡 Po uložení políčko Client Secret neobsahuje nic, ale to je v pořádku 😄

      • plugin»oauthazure»tenant => plugin oauthazure tenant: Directory (tenant) ID
      • plugin»oauthazure»fetchgroups => By default only roles from the JWT are used as user groups. Enabling this option fetches group data.: <Zaškrtnout pokud chceme synchronizovat skupiny což nám zajistil scope GroupMember.Read.All.

        ⚠️ Pokud bychom toto nepotřebovali, odebrat scope z EntraID aplikace!

      • plugin»oauthazure»stripdomain => Strip @domain from preferred_username: [X]

        📋 Aby užiatelské jméno byl pouze username a ne UPN.