Selfhosting mkdocs (mkdocs-material) on a vps under the wiki
subdomain¶
the quick and dirty guide
Prerequisites:
- You should have your own VPS with NGINX installed (if you followed landchad.net's guide you should be pretty good to go!)
- Debian but it should be the same for different distros
1. Create a subdomain for your wiki (e.g. wiki
)¶
- Go to your DNS provider
- Manage DNS records
- Create an
A
record that points to your server's IPv4: - Create a
AAAA
recordthat points to your server's IPv6:
2. Setting up your mkdocs (or mkdocs-material) website¶
I'm not entirely sure if it's needed but create 2 files named CNAME
(no extension, just CNAME) and place one in the root directory (outside of /docs
) and one in /docs
. Enter the URL of your website - in my case that will be wiki.vodoraslo.club
and save it. Just one line, don't add additional spaces. Both of the files must point to the same URL so copy paste it!
On creating content:
- All markdown files should be under the
/docs
folder - Create an
/img
folder for images, gifs and videos
Seeing how your website looks in real time is done with the following command - mkdocs serve
. Use it in the root directory
Building your website (generating HTML files from markdown) is done with the following command - mkdocs build
. The result should be a new folder called /site
3. Setting NGINX up¶
- Log in your VPS through SSH
- Create the following file in
/etc/nginx/sites-available
:nano /etc/nginx/sites-available/wikimkdocs
- Create a folder where your
/site
files will reside in -mkdir /var/www/wikimkdocs
- Paste this in and change
example.org
towiki.YOURDOMAIN.COM
, also check ifroot /var/www/mysite
corresponds to the folder you made in3.
: ln -s /etc/nginx/sites-available/wikimkdocs /etc/nginx/sites-enabled
systemctl reload nginx
. It should reload with no issuescertbot --nginx
and either select only the wiki domain or do all domains- Now you have to get
/site
into/var/www/wikimkdocs
.
4. Getting content into /var/www/wikimkdocs
¶
I did this by setting up a git repository for my wiki, then git pull
ing to get the differences. I DO NOT COMMIT FROM THE VPS!
Then I just use rsync:
WARNING
Do bear in mind that I'm in the git repository directory before executing this command!
The first command will remove everything in that directory, then rsync will populate it with the newest stuff.
Then do another systemctl reload nginx
just to be sure
If you followed this guide, you should have a wiki
subdomain for your wiki, SSL and whatever content you made on it! :)