MediaWiki was developed originally for Wikipedia and has grown to support lots of sites. With this in mind you may consider installing MediaWiki and running a local wiki, especially as MediaWiki provides instructions on specific operating system installs.
In an effort to speed up installs I’ve created an Ansible playbook to carry out the MediaWiki install and initial database (MySQL) configuration on Ubuntu. The playbook calls on a variables file (var.yml) which currently contains some dummy values whilst I test and improve the playbook. In a production environment I would recommend using Ansible Vault to encrypt the variables file so that no secret / sensitive information is stored in the playbook, stored accidentally in a repository or has to be manually entered during the play.
As I’m currently testing the playbook I’ve got it to install both MediaWiki and MySQL on the same instance, if you have spare compute resources then I would suggest installing the database on a separate instance.
Final Note, and a slight warning – My playbook currently leaves the MySQL database root password as the default (blank). Outside of a test run / test environment please make sure to change this to a secure password.
So what does the playbook do?
First it pulls in the vars.yml file which contains the download URL of MediaWiki, a temp destination to store the download, where to extract the archive to, a database name, a database username and a database password (a test value, please don’t use 12345 as a password).
The playbook then cycles through a list of packages and installs them. This list is from the MediaWiki install requirements, plus php-intl (as PHP warned it was missing on my initial run) and python3-pip as it I use it to pip install some Python3 modules (for SQL).
Then the playbook downloads / extracts the MediaWiki archive and creates a symbolic link to the install so that /var/www/html/mediawiki links to /var/lib/mediawiki/mediawiki-1.37.1
Apache2 was installed in the package list, and is being used as the web server. As MediaWiki is the only site I’m running on this compute instance I have got Ansible to update the Apache2 enabled sites to point straight to the MediaWiki symlink and restart Apache2, so that the changes show.
I have installed community.mysql on my Ansible box so that I can use MySQL commands in the Ansible playbook, this install is done via the command:
ansible-galaxy collection install community.mysql
Interacting with MySQL via Python (which Ansible uses) requires that the PyMySQL Python module is installed on the instance where the commands run (e.g. the remote instance, not the Ansible instance), so the playbook installs PyMySQL and makes sure that the MySQL service has started / is enabled (to start each reboot).
As MediaWiki requires a database and a database user (it is not recommended to use the database root user) I then have the Ansible playbook create them.
If you’ve read my previous blog post (regarding SOCKS proxy), then you may have seen that playbook successfully installs MediaWiki,