1,575
edits
Changes
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..."
[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 [https://www.wikipedia.org/ Wikipedia] and this wiki too!
This article describes how I setup a MediaWiki server on a [https://www.debian.org/ Debian] 10 based [https://linuxcontainers.org/ Linux Container (LXC)] under [https://www.proxmox.com/en/ Proxmox] and made the page available using an [https://httpd.apache.org Apache2] [https://en.wikipedia.org/wiki/Reverse_proxy 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 ([https://www.mediawiki.org/wiki/MediaWiki_1.31 1.31.14] at the time of this writing) even though the latest available version is [https://www.mediawiki.org/wiki/MediaWiki_1.36 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 [https://www.nano-editor.org/ 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=
#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 <pre>apt update</pre>
##run <pre>apt upgrade</pre>
##run <pre>apt install sudo unzip</pre>
#Update the timezone
##run <pre>timedatectl set-timezone America/New_York</pre>
##*change ''America/New_York'' to a location relevant to your physical location using the "TZ database name" in this [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones table]
#Add a user and give them sudo access by running <pre>useradd admin</pre> and <pre>usermod -aG sudo admin</pre>
#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 <pre>sudo apt install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring</pre>
##Next install some useful extra packages by running <pre>sudo apt install php-apcu php-intl imagemagick php-gd php-curl git</pre>
##Restart apache2 to make it aware of ''php-apcu'' by running <pre>sudo service apache2 reload</pre>
#Setup MariaDB
##Secure the MariaDB installation by running <pre>sudo mysql_secure_installation</pre>
###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 <pre>sudo mysql -u root -p</pre>
##Create the mediawiki MariaDB user by typing the following at the ''MariaDB [(none)]>'' prompt <pre>CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';</pre>
##Create the mediawiki database by entering <pre>CREATE DATABASE mediawikidb;</pre>
##Grant necessary privileges to the mediawiki user on the mediawiki database by entering <pre>USE mediawikidb;</pre> and <pre>GRANT ALL ON mediawikidb.* TO 'mediawiki_user'@'localhost';</pre>
##exit the MariaDB console by running <pre>exit;</pre>
#Configure PHP
##edit the apache2 php config file by running <pre>sudo nano /etc/php/7.3/apache2/php.ini</pre>
###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
#Configure Apache2
##Add an Alias for your wiki by running <pre>sudo nano /etc/apache2/apache2.conf</pre>
###add a line, at the bottom, that says ''Alias /wiki /var/lib/mediawiki'' to the bottom of the file
=Install & Configure MediaWiki=
#run <pre>sudo apt install mediawiki</pre>
#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:''' '''<span style="color: red"><--- 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!</span>'''
###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
###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 <pre>sudo scp ~/Downloads/LocalSettings.php user@server:~/</pre>
##on the server machine run <pre>sudo mv ~/LocalSettings.php /etc/mediawiki/</pre>
#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 <pre>cd ~</pre>
###run something like (using download link obtained from above) <pre>wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_31-6418f42.tar.gz</pre>
###run <pre>sudo tar -xzf MobileFrontend-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/MobileFrontend/</pre>
###run <pre>rm MobileFrontend-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable MobileFrontend wfLoadExtension( 'MobileFrontend' ); $wgMFAutodetectMobileView = true; $wgMFDefaultSkinClass = 'SkinMinerva';</pre>
##'''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) <pre>wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_31-0eb68cc.tar.gz</pre>
###run <pre>sudo tar -xzf LabeledSectionTransclusion-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/LabeledSectionTransclusion/</pre>
###run <pre>rm LabeledSectionTransclusion-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable LabeledSectionTransclusion wfLoadExtension( 'LabeledSectionTransclusion' );</pre>
##''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 <pre>wget https://extdist.wmflabs.org/dist/extensions/IframePage-REL1_31-1414af9.tar.gz</pre>
###run <pre>sudo tar -xzf IframePage-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/IframePage/</pre>
###run <pre>rm IframePage-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable IframePage require_once "$IP/extensions/IframePage/IframePage.php"; $wgIframePageSrc= array( /* REQUIRED! */ );</pre>
#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 <pre># 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;</pre>
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 <pre>sudo nano /var/www/html/index.html</pre> and enter the following into the file
<nowiki><head>
<meta http-equiv="refresh" content="0; url=http://server/mediawiki/" />
</head></nowiki>
[[Category: Linux]]
This article describes how I setup a MediaWiki server on a [https://www.debian.org/ Debian] 10 based [https://linuxcontainers.org/ Linux Container (LXC)] under [https://www.proxmox.com/en/ Proxmox] and made the page available using an [https://httpd.apache.org Apache2] [https://en.wikipedia.org/wiki/Reverse_proxy 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 ([https://www.mediawiki.org/wiki/MediaWiki_1.31 1.31.14] at the time of this writing) even though the latest available version is [https://www.mediawiki.org/wiki/MediaWiki_1.36 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 [https://www.nano-editor.org/ 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=
#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 <pre>apt update</pre>
##run <pre>apt upgrade</pre>
##run <pre>apt install sudo unzip</pre>
#Update the timezone
##run <pre>timedatectl set-timezone America/New_York</pre>
##*change ''America/New_York'' to a location relevant to your physical location using the "TZ database name" in this [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones table]
#Add a user and give them sudo access by running <pre>useradd admin</pre> and <pre>usermod -aG sudo admin</pre>
#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 <pre>sudo apt install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring</pre>
##Next install some useful extra packages by running <pre>sudo apt install php-apcu php-intl imagemagick php-gd php-curl git</pre>
##Restart apache2 to make it aware of ''php-apcu'' by running <pre>sudo service apache2 reload</pre>
#Setup MariaDB
##Secure the MariaDB installation by running <pre>sudo mysql_secure_installation</pre>
###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 <pre>sudo mysql -u root -p</pre>
##Create the mediawiki MariaDB user by typing the following at the ''MariaDB [(none)]>'' prompt <pre>CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';</pre>
##Create the mediawiki database by entering <pre>CREATE DATABASE mediawikidb;</pre>
##Grant necessary privileges to the mediawiki user on the mediawiki database by entering <pre>USE mediawikidb;</pre> and <pre>GRANT ALL ON mediawikidb.* TO 'mediawiki_user'@'localhost';</pre>
##exit the MariaDB console by running <pre>exit;</pre>
#Configure PHP
##edit the apache2 php config file by running <pre>sudo nano /etc/php/7.3/apache2/php.ini</pre>
###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
#Configure Apache2
##Add an Alias for your wiki by running <pre>sudo nano /etc/apache2/apache2.conf</pre>
###add a line, at the bottom, that says ''Alias /wiki /var/lib/mediawiki'' to the bottom of the file
=Install & Configure MediaWiki=
#run <pre>sudo apt install mediawiki</pre>
#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:''' '''<span style="color: red"><--- 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!</span>'''
###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
###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 <pre>sudo scp ~/Downloads/LocalSettings.php user@server:~/</pre>
##on the server machine run <pre>sudo mv ~/LocalSettings.php /etc/mediawiki/</pre>
#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 <pre>cd ~</pre>
###run something like (using download link obtained from above) <pre>wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_31-6418f42.tar.gz</pre>
###run <pre>sudo tar -xzf MobileFrontend-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/MobileFrontend/</pre>
###run <pre>rm MobileFrontend-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable MobileFrontend wfLoadExtension( 'MobileFrontend' ); $wgMFAutodetectMobileView = true; $wgMFDefaultSkinClass = 'SkinMinerva';</pre>
##'''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) <pre>wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_31-0eb68cc.tar.gz</pre>
###run <pre>sudo tar -xzf LabeledSectionTransclusion-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/LabeledSectionTransclusion/</pre>
###run <pre>rm LabeledSectionTransclusion-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable LabeledSectionTransclusion wfLoadExtension( 'LabeledSectionTransclusion' );</pre>
##''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 <pre>wget https://extdist.wmflabs.org/dist/extensions/IframePage-REL1_31-1414af9.tar.gz</pre>
###run <pre>sudo tar -xzf IframePage-*.tar.gz -C /usr/share/mediawiki/extensions</pre>
###run <pre>sudo chown -R root:root /usr/share/mediawiki/extensions/IframePage/</pre>
###run <pre>rm IframePage-*.tar.gz</pre>
###run <pre>sudo nano /etc/mediawiki/LocalSettings.php</pre> and add the following to the bottom <pre># Enable IframePage require_once "$IP/extensions/IframePage/IframePage.php"; $wgIframePageSrc= array( /* REQUIRED! */ );</pre>
#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 <pre># 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;</pre>
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 <pre>sudo nano /var/www/html/index.html</pre> and enter the following into the file
<nowiki><head>
<meta http-equiv="refresh" content="0; url=http://server/mediawiki/" />
</head></nowiki>
[[Category: Linux]]