Difference between revisions of "How to Setup a MediaWiki 1.31 Server on a Debian 10 Proxmox container"

From steamWiki
Jump to: navigation, search
(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>
###add a line, at the bottom, that says ''Alias /wiki /var/lib/mediawiki'' to the bottom of the file
 
  
 
=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.

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 by running
    useradd admin
    and
    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 by running
      sudo apt install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring
    2. Next install some useful extra packages by running
      sudo apt install php-apcu php-intl imagemagick php-gd php-curl git
    3. Restart apache2 to make it aware of php-apcu by running
      sudo service apache2 reload
  2. Setup MariaDB
    1. Secure the MariaDB installation by running
      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 by entering
      CREATE DATABASE mediawikidb;
    5. Grant necessary privileges to the mediawiki user on the mediawiki database by entering
      USE mediawikidb;
      and
      GRANT ALL ON mediawikidb.* TO 'mediawiki_user'@'localhost';
    6. exit the MariaDB console by running
      exit;
  3. Configure PHP
    1. edit the apache2 php config file by running
      sudo nano /etc/php/7.3/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 by running
      sudo nano /etc/apache2/apache2.conf
      and adding a line, at the bottom, that says
      Alias /wiki /var/lib/mediawiki

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
        • Special pages
          • Nuke
          • Renameuser
        • Editors
          • WikiEditor
        • Parser hooks
          • ImageMap
          • InputBox
          • ParserFunctions
          • SyntaxHighlight_GeSHi
        • Media handlers
          • PdfHandler
      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 for MediaWik 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MobileFrontend
      2. to make sure you're in your home directory run
        cd ~
      3. run something like (using download link obtained from above)
        wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_31-6418f42.tar.gz
      4. run
        sudo tar -xzf MobileFrontend-*.tar.gz -C /usr/share/mediawiki/extensions
      5. run
        sudo chown -R root:root /usr/share/mediawiki/extensions/MobileFrontend/
      6. run
        rm MobileFrontend-*.tar.gz
      7. 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 allow you to link labelled section of a page to another page
      1. Get the download link for MediaWiki 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/LabeledSectionTransclusion
      2. run something like (using download link obtained from above)
        wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_31-0eb68cc.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. Get the download link for MediaWik 1.31 from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/IframePage
      2. run
        wget https://extdist.wmflabs.org/dist/extensions/IframePage-REL1_31-1414af9.tar.gz
      3. run
        sudo tar -xzf IframePage-*.tar.gz -C /usr/share/mediawiki/extensions
      4. run
        sudo chown -R root:root /usr/share/mediawiki/extensions/IframePage/
      5. run
        rm IframePage-*.tar.gz
      6. 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;
    $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 run
sudo nano /var/www/html/index.html
and enter the following into the file
<head>
        <meta http-equiv="refresh" content="0; url=http://server/mediawiki/" />
</head>