Difference between revisions of "How to Setup a MediaWiki 1.31 Server on a Debian 10 Proxmox container"
(Created page with "[https://www.mediawiki.org/ MediaWiki] is an excellent software package that almost instantly gives you a highly functional, highly configurable wiki. It is what powers [http...") |
|||
Line 39: | Line 39: | ||
###ensure that that ''memory_limit'' is set to at least 128M | ###ensure that that ''memory_limit'' is set to at least 128M | ||
#Configure Apache2 | #Configure Apache2 | ||
− | ##Add an Alias for your wiki by running <pre>sudo nano /etc/apache2/apache2.conf</pre> | + | ##Add an Alias for your wiki by running <pre>sudo nano /etc/apache2/apache2.conf</pre> and adding a line, at the bottom, that says <pre>Alias /wiki /var/lib/mediawiki</pre> |
− | |||
=Install & Configure MediaWiki= | =Install & Configure MediaWiki= |
Revision as of 09:43, 8 July 2021
MediaWiki is an excellent software package that almost instantly gives you a highly functional, highly configurable wiki. It is what powers Wikipedia and this wiki too!
This article describes how I setup a MediaWiki server on a Debian 10 based Linux Container (LXC) under Proxmox and made the page available using an Apache2 Reverse Proxy.
In the case of a MediaWiki instance I'm more interested in stability, ease of installation, and ease of updating over having the latest features. Therefore I'm installing the version distributed with Debian 10 (1.31.14 at the time of this writing) even though the latest available version is 1.36.1 at the time of this writing). Furthermore I'll be configuring MediaWiki the way I like it and installing some extra packages and extensions that I find useful.
I use nano as the command line text editor of choice here. Once you've finished editing the text file click Ctrl-X and then Y to save the file.
Contents
Setup the Container
- Using the Proxmox web interface, create a new Container using the Debian 9 template.
- Log into the container, with the root account, using the Proxmox web console
- Update, Upgrade, and Install a few packages
- run
apt update
- run
apt upgrade
- run
apt install sudo unzip
- run
- Update the timezone
- run
timedatectl set-timezone America/New_York
- change America/New_York to a location relevant to your physical location using the "TZ database name" in this table
- run
- Add a user and give them sudo access by running
useradd admin
andusermod -aG sudo admin
- Exit the web console and ssh in as the admin user
Setup Prerequisite Packages
- Install the packages we'll need
- First install the required prerequisite packages by running
sudo apt install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring
- Next install some useful extra packages by running
sudo apt install php-apcu php-intl imagemagick php-gd php-curl git
- Restart apache2 to make it aware of php-apcu by running
sudo service apache2 reload
- First install the required prerequisite packages by running
- Setup MariaDB
- Secure the MariaDB installation by running
sudo mysql_secure_installation
- Ensure the root password is set and answer yes to all of the questions
- Log in to MariaDB with the following command. Enter your root password when prompted
sudo mysql -u root -p
- Create the mediawiki MariaDB user by typing the following at the MariaDB [(none)]> prompt
CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';
- Create the mediawiki database by entering
CREATE DATABASE mediawikidb;
- Grant necessary privileges to the mediawiki user on the mediawiki database by entering
USE mediawikidb;
andGRANT ALL ON mediawikidb.* TO 'mediawiki_user'@'localhost';
- exit the MariaDB console by running
exit;
- Secure the MariaDB installation by running
- Configure PHP
- edit the apache2 php config file by running
sudo nano /etc/php/7.3/apache2/php.ini
- change upload_max_filesize to at least 20M
- change post_max_size to at least 20M
- ensure that that memory_limit is set to at least 128M
- edit the apache2 php config file by running
- Configure Apache2
- Add an Alias for your wiki by running
sudo nano /etc/apache2/apache2.conf
and adding a line, at the bottom, that saysAlias /wiki /var/lib/mediawiki
- Add an Alias for your wiki by running
Install & Configure MediaWiki
- run
sudo apt install mediawiki
- navigate a web browser to http://server/mediawiki/
- click set up the wiki
- click Continue
- click Continue
- on the Connect to database page
- change Database name: to mediawikidb
- change Database username: to mediawiki_user
- change Database password: to THISpasswordSHOULDbeCHANGED
- click Continue
- click Continue
- on the Name page
- on the name of your wiki in Name of the wiki
- setup an admin account
- click Continue
- on the Options page
- choose your User rights profile: <--- THIS IS IMPORTANT make sure the wiki is setup the way you want it to be. Be aware that an open wiki or a wiki that allows user to create and authenticate their own accounts will almost certainly result in your wiki getting vandalized by automated advertisement/hacking scripts!
- choose your license
- decide if you want email support
- decide if you want to disable any skins
- I recommend enabling the following extensions
- Special pages
- Nuke
- Renameuser
- Editors
- WikiEditor
- Parser hooks
- ImageMap
- InputBox
- ParserFunctions
- SyntaxHighlight_GeSHi
- Media handlers
- PdfHandler
- Special pages
- turn on Enable file uploads
- click Continue
- click Continue
- click Continue
- Move the LocalSettings.php file generated by the installer to /etc/mediawiki/LocalSettings.php on the target machine with the following
- on the browser machine run
sudo scp ~/Downloads/LocalSettings.php user@server:~/
- on the server machine run
sudo mv ~/LocalSettings.php /etc/mediawiki/
- on the browser machine run
- Install and Enable some extra extensions
- MobileFrontend to give your wiki a nicely formatted view when seen from a mobile device
- Get the download link for MediaWik 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MobileFrontend
- to make sure you're in your home directory run
cd ~
- run something like (using download link obtained from above)
wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_31-6418f42.tar.gz
- run
sudo tar -xzf MobileFrontend-*.tar.gz -C /usr/share/mediawiki/extensions
- run
sudo chown -R root:root /usr/share/mediawiki/extensions/MobileFrontend/
- run
rm MobileFrontend-*.tar.gz
- run
sudo nano /etc/mediawiki/LocalSettings.php
and add the following to the bottom# Enable MobileFrontend wfLoadExtension( 'MobileFrontend' ); $wgMFAutodetectMobileView = true; $wgMFDefaultSkinClass = 'SkinMinerva';
- LabeledSectionTransclusion to allow you to link labelled section of a page to another page
- Get the download link for MediaWiki 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/LabeledSectionTransclusion
- run something like (using download link obtained from above)
wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_31-0eb68cc.tar.gz
- run
sudo tar -xzf LabeledSectionTransclusion-*.tar.gz -C /usr/share/mediawiki/extensions
- run
sudo chown -R root:root /usr/share/mediawiki/extensions/LabeledSectionTransclusion/
- run
rm LabeledSectionTransclusion-*.tar.gz
- run
sudo nano /etc/mediawiki/LocalSettings.php
and add the following to the bottom# Enable LabeledSectionTransclusion wfLoadExtension( 'LabeledSectionTransclusion' );
- IframePage to allow you load iFrames from other sites into your wiki pages
- Get the download link for MediaWik 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/IframePage
- run
wget https://extdist.wmflabs.org/dist/extensions/IframePage-REL1_31-1414af9.tar.gz
- run
sudo tar -xzf IframePage-*.tar.gz -C /usr/share/mediawiki/extensions
- run
sudo chown -R root:root /usr/share/mediawiki/extensions/IframePage/
- run
rm IframePage-*.tar.gz
- run
sudo nano /etc/mediawiki/LocalSettings.php
and add the following to the bottom# Enable IframePage require_once "$IP/extensions/IframePage/IframePage.php"; $wgIframePageSrc= array( /* REQUIRED! */ );
- MobileFrontend to give your wiki a nicely formatted view when seen from a mobile device
- Enable a wider array of file uploads by running sudo nano /etc/mediawiki/LocalSettings.php and placing the following at the bottom of the file
# Accepted Upload File Extensions $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'tiff', 'bmp', 'doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx', 'odt', 'ods', 'odp', 'odg', 'py', 'py3', 'pdf', 'pem' ); $wgFileBlacklist = array(); $wgStrictFileExtensions = false; $wgMimeTypeBlacklist = array(); $wgVerifyMimeType = false; $wgMaxUploadSize = 20971520;
You're done! Go visit http://server/mediawiki to start using your brand new wiki!
Bonus
If you want to visit http://server and have it automatically, instantly, redirect the user to http://server/mediawiki runsudo nano /var/www/html/index.htmland enter the following into the file
<head> <meta http-equiv="refresh" content="0; url=http://server/mediawiki/" /> </head>