Herbalist At Large - Classes!

Installing DokuWiki!

Let's add DokuWiki to our server!

SSH into your sever

[using SSH] Remember to

apt update

and

apt upgrade

every time!

Install dependencies

apt install php-xml php-mbstring php-zip php-intl php-gd

(You probably have these on your server already but it doesn't hurt)

Install DokuWiki

Install DokuWiki, move it to the correct directory, and give the correct permissions by:

wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
tar xzvf dokuwiki-stable.tgz
mv dokuwiki-*/ /var/www/dokuwiki
chown -R www-data:www-data /var/www/dokuwiki

Create the nginx config file

Create a config file with:

nano /etc/nginx/sites-available/dokuwiki

and paste the following file into it. Replace YOURCLASSESSUBDOMAIN.YOURMAINDOMAIN.COM with something like classes.yourdomain.com (for example mine is classes.herbalist-at-large.xyz). If you choose to use individual sites in the following section, remember that each individual class page will be another subdomain on top of this: classname.yourclassessubdomain.yourmaindomain.com (for example, this page, webdev.classes.herbalist-at-large.xyz).

server {
    listen 80;
    listen [::]:80;
    server_name YOURCLASSESSUBDOMAIN.YOURMAINDOMAIN.COM;
    
    client_max_body_size 4G;
    client_body_buffer_size 128k;

    root /var/www/dokuwiki;
    index doku.php;

    #Remember to comment the below out when you're installing, and uncomment it when done.
    #location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }

    #Support for X-Accel-Redirect
    location ~ ^/data/ { internal ; }

    location ~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$ {
        expires 365d;
    }

    location / { try_files $uri $uri/ @dokuwiki; }

    location @dokuwiki {
        # rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1&$args last;
    }

    location ~ \.php$ {
        try_files $uri $uri/ /doku.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REDIRECT_STATUS 200;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        # fastcgi_pass unix:/var/run/php5-fpm.sock; #old php version
    }
}

Enable the website

Enable your dokuwiki website by linking the sites-available config file to the sites-enabled directory:

ln -s /etc/nginx/sites-available/dokuwiki /etc/nginx/sites-enabled/

Add your domain record

Go to porkbun and create A and AAAA domain records for whatever you put as YOURCLASSDOMAIN.YOURMAINDOMAIN.com using your same old IVP4 and IVP6 IP addresses.

Restart nginx and php

systemctl restart nginx && systemctl restart php8.4-fpm

Get HTTPS for your site

Go ahead and run

certbot --nginx

Select your new domain, and voila. The bot we started waaaay back in module 2 will keep our SSL certificates good for us.

Go ahead and set up DokuWiki!

Go to YOURCLASSDOMAIN.YOURMAINDOMAIN.com and follow the prompts:

  1. Give your website a title
  2. ENABLE ACL (this is what lets you use authenticated users)
  3. Create your own account with your username, screen name, email and password
  4. Recommended (you can change this later!): Set wiki to “closed”
  5. Recommended (you can change this later!): Disable new account sign-ups

Edit your nginx file one last time

To secure our site, head back to the command line (or SSH back in) and run

nano /etc/nginx/sites-available/dokuwiki

To open your nginx config file. Navigate to the lines:

    #Remember to comment the below out when you're installing, and uncomment it when done.
    #location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }

And delete the # from the beginning of the second line, so it looks like this:

    #Remember to comment the below out when you're installing, and uncomment it when done.
    location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }

Exit, save, and close your SSH. All done!

module_7/lesson_1.txt · Last modified: by admin