This guide is to set up the DMC Wiki on a new machine.
On your computer, run the following command:
ssh-keygen -t rsa -b 4096 -C <insert your email here>
Press enter through all prompts.
This will generate two files in the .ssh
folder inside your user folder.
Follow this guide: https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-team/
In the section where it explains what to paste in the New SSH Key
, what you'll paste there is the contents of .ssh/id_rsa.pub
(you can open it up in notepad and copy the whole thing then paste it in the SSH key content
section). You can name the key whatever makes the most sense to you.
Make the server on DigitalOcean. You can choose either Ubuntu 22.04 (LTS) or Debian 12 Bookworm. This guide works for either one.
Switch to a Regular (SSD) disk type, and choose the $6/mo option.
For Choose Authentication Method, you should be able to choose SSH Key and use the key you uploaded to the team in the last step.
Finally, you can change the server's hostname to dmcwiki
or something similar. This is just for our own convenience.
First, get the server's IP from the droplet's menu in DigitalOcean. Then you should be able to run the following command on your computer:
ssh root@<ip of the server>
Run the following command on the server:
apt update && apt upgrade -y
We will use ufw
(aka uncomplicated firewall) to set up the firewalls for the server. First, install ufw
by running the following command:
apt install ufw
Then run all the following commands (you can copy the whole thing and paste it into the ssh window and press enter):
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow http
ufw allow https
ufw enable
These all need to be run before successfully before exiting.
If you have a zip file of the backup from the old server, you can upload it to the new server using the SCP command. On your machine in the same directory as the latest.zip
file:
scp latest.zip root@<ip of the server>:~
This will copy the latest.zip
folder over the network onto the server in the home folder of the root
user.
SSH into the server. Unzip the backup by running:
unzip latest.zip
The old backup hies made has the backup of an entire /var/www
folder. Most of this is no longer needed.
What we will save from this folder is in the var/www/dokuwiki
from the unzipped directory. This can be copied somewhere on the server, does not matter where but remember the path. A common location for dokuwiki is /srv/dokuwiki
, so that would work.
For Dokuwiki to work, you need to have something to run PHP. We will be hooking Caddy into this to actually render the website. The easiest thing to use for this is PHP FPM. To install:
apt install php-fpm
Caddy is the web server we will be setting up to serve the dokuwiki site. It is easier than Apache because it automatically does LetsEncrypt stuff for you under the hood, meaning we get free https
. The config is also easier to understand.
Go to https://github.com/caddyserver/caddy and go to the Releases
section. In the latest release, find the option that ends with _amd64.deb
. Right click that link and select "Copy Link". Then in the server, run the command:
wget <the link you just copied>
Then to install Caddy, run:
apt install <the deb file that you just downloaded>
First, run the following command that will make it so Caddy always starts up when the machine starts. This is helpful for scenarios where something goes wrong and the machine needs to be rebooted.
systemctl enable caddy
We need to edit the file /etc/caddy/Caddyfile
. We can do this with the nano
tool.
Run the command:
nano /etc/caddy/Caddyfile
This will bring up a menu right in the terminal that is very similar to notepad.
Paste the following contents to the bottom of the file:
dmc.wiki {
encode gzip zstd
root * /srv/dokuwiki
#Remember to comment the below forbidden block out when you're installing, and uncomment it when done.
@forbidden path /data/* /conf/* /bin/* /inc/* /install.php
handle @forbidden {
respond * 403
}
#End of the forbidden block
log {
output file /var/log/caddy/dmcwiki.access.log
}
try_files {path} {path}/index.html
route {
handle_path /_media/* {
rewrite * /lib/exe/fetch.php?media={path}&{query}
}
handle_path /_detail/* {
rewrite * /lib/exe/detail.php?media={path}&{query}
}
handle /_export/* {
@export path_regexp export ^/_export/([^/]+)/(.*)
rewrite @export /doku.php?do=export_{re.export.1}&{query}&id={re.export.2}
}
handle / {
rewrite * /doku.php?{query}
}
try_files {path} /doku.php?id={path}&{query}
}
file_server
php_fastcgi unix//run/php/php-fpm.sock
}
Then run the following command to make the config take effect:
systemctl restart caddy
In the Namecheap domain settings, you can set the @
record to point to the IP of the new server instead. After a couple minutes, dmc.wiki
should work again.