Difference between revisions of "How to Setup a MediaWiki 1.27 Server on a Debian 9 Proxmox container"

From steamWiki
Jump to: navigation, search
(Install & Configure MediaWiki)
(Setup Prerequisite Packages)
Line 49: Line 49:
 
##*''sudo nano /etc/php/7.0/apache2/php.ini''
 
##*''sudo nano /etc/php/7.0/apache2/php.ini''
 
###change ''upload_max_filesize'' to at least 20M
 
###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
 
###ensure that that ''memory_limit'' is set to at least 128M
 
#Configure Apache2
 
#Configure Apache2

Revision as of 19:56, 19 June 2019

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 9 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 9 (1.27 at the time of this writing) even though the latest available version is 1.32 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.

Setup the Container

  1. Using the Proxmox web interface, create a new Container using the Debian 9 template.
  2. Log into the container, with the root account, using the Proxmox web console
  3. Update, Upgrade, and Install a few packages
    1. run apt update
    2. run apt upgrade
    3. run apt install sudo unzip
  4. Update the timezone
    1. 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
  5. Add a user and give them sudo access
    1. useradd admin
    2. usermod -aG sudo admin
  6. Exit the web console and ssh in as the admin user

Setup Prerequisite Packages

  1. Install the packages we'll need
    1. First install the required prerequisite packages (note that the package mysql-server actually installs MariaDB which is great! MariaDB is an open-source fork of MySQL).
      • sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring
    2. Next install some useful extra packages
      • sudo apt install php-apcu php-intl imagemagick php-gd php-curl git
    3. Restart apache2 to make it aware of php-apcu
      • sudo service apache2 reload
  2. Setup MariaDB
    1. Secure the MariaDB installation by running the following command
      • sudo mysql_secure_installation
      1. Ensure the root password is set and answer yes to all of the questions
    2. Log in to MariaDB with the following command. Enter your root password when prompted
      • sudo mysql -u root -p
    3. Create the mediawiki MariaDB user by typing the following at the MariaDB [(none)]> prompt
      • CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';
    4. Create the mediawiki database with the following command
      • CREATE DATABASE mediawikidb;
    5. Grant necessary privileges to the mediawiki user on the mediawiki database with the following commands
      • USE mediawikidb;
      • GRANT ALL ON mediawikidb.* TO 'mediawiki_user'@'localhost';
    6. exit the MariaDB console with the following command
      • exit;
  3. Configure PHP
    1. edit the apache2 php config file with the following command
      • sudo nano /etc/php/7.0/apache2/php.ini
      1. change upload_max_filesize to at least 20M
      2. change post_max_size to at least 20M
      3. ensure that that memory_limit is set to at least 128M
  4. Configure Apache2
    1. Add an Alias for your wiki
      1. run sudo nano /etc/apache2/apache2.conf
      2. add Alias /wiki /var/lib/mediawiki to the bottom of the file

Install & Configure MediaWiki

  1. run sudo apt install mediawiki
  2. navigate a web browser to http://server/mediawiki/
    1. click set up the wiki
    2. click Continue
    3. click Continue
    4. on the Connect to database page
      1. change Database name: to mediawikidb
      2. change Database username: to mediawiki_user
      3. change Database password: to THISpasswordSHOULDbeCHANGED
      4. click Continue
    5. click Continue
    6. on the Name page
      1. on the name of your wiki in Name of the wiki
      2. setup an admin account
      3. click Continue
    7. on the Options page
      1. 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!
      2. choose your license
      3. decide if you want email support
      4. decide if you want to disable any skins
      5. I recommend enabling the following extensions
        • ImageMap
        • InputBox
        • Nuke
        • ParserFunctions
        • PdfHandler
        • Renameuser
        • SyntaxHighlight_GeSHi
        • WikiEditor
      6. turn on Enable file uploads
      7. click Continue
      8. click Continue
      9. click Continue
  3. Move the LocalSettings.php file generated by the installer to /etc/mediawiki/LocalSettings.php on the target machine with the following
    1. on the browser machine run sudo scp ~/Downloads/LocalSettings.php user@server:~/
    2. on the server machine run sudo mv ~/LocalSettings.php /etc/mediawiki/"
  4. Install and Enable some extra extensions
    1. MobileFrontend to give your wiki a nicely formatted view when seen from a mobile device
      1. Get the download link from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MobileFrontend
      2. run wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_27-717861c.tar.gz
      3. run sudo tar -xzf MobileFrontend-*.tar.gz -C /usr/share/mediawiki/extensions
      4. run sudo chown -R root:root /usr/share/mediawiki/extensions/MobileFrontend/
      5. run rm MobileFrontend-*.tar.gz
      6. run sudo nano /etc/mediawiki/LocalSettings.php and add the following to the bottom
        • # Enable MobileFrontend
        • wfLoadExtension( 'MobileFrontend' );
        • $wgMFAutodetectMobileView = true;
        • $wgMFDefaultSkinClass = 'SkinMinerva';
    2. LabeledSectionTransclusion to all you to link labelled section of a page to another page
      1. Get the download link from: https://www.mediawiki.org/wiki/Special:ExtensionDistributor/LabeledSectionTransclusion
      2. run wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_27-9212396.tar.gz
      3. run sudo tar -xzf LabeledSectionTransclusion-*.tar.gz -C /usr/share/mediawiki/extensions
      4. run sudo chown -R root:root /usr/share/mediawiki/extensions/LabeledSectionTransclusion/
      5. run rm LabeledSectionTransclusion-*.tar.gz
      6. run sudo nano /etc/mediawiki/LocalSettings.php and add the following to the bottom
        • # Enable LabeledSectionTransclusion
        • wfLoadExtension( 'LabeledSectionTransclusion' );
    3. IframePage to allow you load iFrames from other sites into your wiki pages
      1. run wget https://extdist.wmflabs.org/dist/extensions/IframePage-REL1_27-ca7f4fc.tar.gz
      2. run sudo tar -xzf IframePage-*.tar.gz -C /usr/share/mediawiki/extensions
      3. run sudo chown -R root:root /usr/share/mediawiki/extensions/IframePage/
      4. run rm IframePage-*.tar.gz
      5. 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! */ );
  5. 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;

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 run sudo nano /var/www/html/index.html and enter the following into the file

<head>
        <meta http-equiv="refresh" content="0; url=http://wiki/mediawiki/" />
</head>