Setting up MediaWiki: Difference between revisions
No edit summary |
No edit summary |
||
Line 52: | Line 52: | ||
=== Installing the MediaWiki release === | === Installing the MediaWiki release === | ||
There's no fancy 1-click installation script or the like (or I haven't found one). To install MediaWiki you'll have to download the archived file, put it somewhere nginx can access, and configure Nginx to serve that. | There's no fancy 1-click installation script or the like (or I haven't found one). To install MediaWiki you'll have to download the archived file, put it somewhere nginx can access, and configure Nginx to serve that. | ||
== Making MediaWiki better == | |||
=== HTTPS and automatic certificate renewal with Certbot === | === HTTPS and automatic certificate renewal with Certbot === | ||
Line 72: | Line 74: | ||
My opinion is if you dislike having a question mark (?) in technically every URL of your site, and you have access to the actual web server software configuration, i.e. not using some lazy hosting service (I don't know if there is any service provider that lets people create MediaWiki instances like WordPress instances), you should do this. | My opinion is if you dislike having a question mark (?) in technically every URL of your site, and you have access to the actual web server software configuration, i.e. not using some lazy hosting service (I don't know if there is any service provider that lets people create MediaWiki instances like WordPress instances), you should do this. | ||
=== Templates === | |||
It's not wrong to say that any good MediaWiki site will be based on tons of templates. Templates can save you a lot of time when typesetting. | |||
A good starting point is MediaWiki and Wikipedia. Use their templates and you can even preseve a level of compatibility between your contents and theirs. | |||
Any MediaWiki site will have a pair of pages called 'Special:Import' and 'Special:Export'. For example, on this site, they are [[Special:Import]] and [[Special:Export]]. These can be used to dump and load any page, including templates, from a MediaWiki instance. | |||
Checking 'Include Templates' on export will also export all the template dependencies of the page you're exporting, which is very useful. As I have said in the beginning of this section, MediaWiki sites are based on tons of templates, and templates are often based on other templates. Importing a single template most probably will be of no use. | |||
=== Extensions === | |||
MediaWiki comes with quite a few extensions with its release, but usually they're not enough. | |||
Be sure to visit |
Revision as of 13:25, 4 July 2023
This might seem somewhat amusing, having a how to set up MediaWiki inside a MediaWiki, at first thought.
However it's actually quite important as people (I) forget the process how they done something 5 weeks after the initial action, and software they always fail in one way or another.
So as a panic suppressor in case something goes wrong, I will keep track of how this MediaWiki instance was set up. This way I can look at this and figure out how to fix the problem, hopefully.
Preparations
The process can't really be done without the help of ChatGPT. Although its knowledge is cutoff at September 2021 (or as it insists), there seem to be sufficient MediaWiki-related knowledge in OpenAI's pandora box.
But you essentially cannot set up a MediaWiki only with ChatGPT. You need
- A (Linux) server. I prefer APT-based distros like Debian or Ubuntu, I might migrate to NixOS when I master the dark arts of Nix but not now. Linux because I don't really know how to work with any other server OSes.
- Web server, Apache 2 or Nginx. I use Nginx because it advertises itself to be 'a lightweight web server' and the name is cooler.
- PHP and all the necessary modules. Will discuss in detail in relative sections.
- php-intl for Unicode parsing. Probably useful for a multilingual Wiki like this.
- Certbot for setting up HTTPS certificate and automatically renewing it. Skip this if you like the terrifying 'Not secure' prompt.
- Preferably a domain name. I am not sure if you can get a HTTPS cert with only the IP address. My knowledge says you can't.
- MySQL or PostgreSQL or SQLite. These are the 3 options supported and required by MediaWiki to set up the database. I somehow managed to break MariaDB completely on this server so I had to resort to SQLite because it looked like the least troublesome. Using some MySQL compatible might be the most traditional choice but someone close said Postgre is ages ahead of MySQL so I really have no idea now.
- Several essential Linux utilities such as ssh, wget, tar/unzip/7z, etc, etc.
- imagemagick (convert) for MediaWiki to generate thumbnails on the fly.
- ufw if you want to open up ports without having to have an American fleet.
- I'll add to this if I notice anything I forgot.
Environment setup
The whole thing starts with setting up the Linux server but we'll skip it here. Nowadays you just go into any VPS provider and pick their cheapest plan and you usually get a working Linux server with public IP address. That's very neat if you ask me.
I'll also skip the domain name acquisition and DNS setup because I know neither how it actually works nor how I made it to work. That should be a proof that any dummy can do it if they decided to.
Suppose that the most essential utilities are already ready installed, I'll start from Nginx.
Installing Nginx, PHP and SQLite
Do a apt update first.
sudo apt update
Start with Nginx and SQLite. PHP has a lot of modules that come in individual packages, so I'll list them later.
sudo apt install nginx sqlite3
Now for PHP and all its modules.
sudo apt install php php-sqlite3 php-fpm php-xml php-mbstring php-intl php-apcu
That's a lot, but I'll be very kind to explain what each are for.
- sqlite3: As the name suggests, enabling PHP manipulation of SQLite.
- fpm: FastCGI Process Manager. This has something to do with pooling and request managing, but honestly I don't know much more.
- xml: XML.
- mbstring, intl: Multi-byte string and International. Both used to manage complex characters and international locales, if I understand correctly.
- apcu: Alternative PHP Cache (user). Used for caching. Something.
Installing the MediaWiki release
There's no fancy 1-click installation script or the like (or I haven't found one). To install MediaWiki you'll have to download the archived file, put it somewhere nginx can access, and configure Nginx to serve that.
Making MediaWiki better
HTTPS and automatic certificate renewal with Certbot
Enabling HTTPS has a lot of benefits as well as many hassles. Good news is that with the utility program Certbot a lot can be automated, eliminating most of the hassles.
Better news is that Certbot has a super intuitive and understandable instructions page which basically eliminates any questions.
Pretty URL
This is the most tricky part because it involves a lot of Nginx configurations. I haven't really fixed this site completely now, but I can have a say or two on this matter anyways.
The default MediaWiki, being a PHP application, will use URLs which look like these:
https://novoyuuparosk.me/index.php?title=Some_Page
While anyone familiar with Wikipedia will instantly notice that Wikipedia's URLs look this way:
https://en.wikipedia.org/wiki/Some_Page
According to MediaWiki's guide on Short URL, there are advantages and disadvantages using short, or pretty, URLs.
My opinion is if you dislike having a question mark (?) in technically every URL of your site, and you have access to the actual web server software configuration, i.e. not using some lazy hosting service (I don't know if there is any service provider that lets people create MediaWiki instances like WordPress instances), you should do this.
Templates
It's not wrong to say that any good MediaWiki site will be based on tons of templates. Templates can save you a lot of time when typesetting.
A good starting point is MediaWiki and Wikipedia. Use their templates and you can even preseve a level of compatibility between your contents and theirs.
Any MediaWiki site will have a pair of pages called 'Special:Import' and 'Special:Export'. For example, on this site, they are Special:Import and Special:Export. These can be used to dump and load any page, including templates, from a MediaWiki instance.
Checking 'Include Templates' on export will also export all the template dependencies of the page you're exporting, which is very useful. As I have said in the beginning of this section, MediaWiki sites are based on tons of templates, and templates are often based on other templates. Importing a single template most probably will be of no use.
Extensions
MediaWiki comes with quite a few extensions with its release, but usually they're not enough.
Be sure to visit