Install Mediawiki: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(26 intermediate revisions by the same user not shown)
Line 77: Line 77:
     fastcgi_pass unix:/run/php/php7.3-fpm.sock;
     fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }
  }
First test if the <code>nginx</code> if oke:
sudo nginx -t
And now reload <code>nginx</code> to apply the changes you made to this config file:
$ sudo service nginx reload


To see if php works now, you can make a php file in <code>/var/www/html/</code> called <code>test.php</code>:
To see if php works now, you can make a php file in <code>/var/www/html/</code> called <code>test.php</code>:
Line 106: Line 114:
Rename the wiki folder something short, like "wiki".
Rename the wiki folder something short, like "wiki".


  mv mediawiki-1.35.1 wiki
  mv mediawiki-1.38.4 wiki


== Configure the URL ==  
== Configure the URL ==  
Line 133: Line 141:
First '''log in''' into MariaDB as '''root''':
First '''log in''' into MariaDB as '''root''':


  $ sudo mysql -u root -p
  $ sudo mysql -u root  


Create a '''new database''':
Create a '''new database''':


('''Note''': replace "<NAMEOFYOURWIKI>" with the name of your wiki, for example: mywiki.)
('''Note''': replace "NAMEOFYOURDATABASE" with the name of your wiki, for example: mywiki.)


  CREATE DATABASE <NAMEOFYOURWIKI>;
CREATE DATABASE '''NAMEOFYOURDATABASE''';


Create a '''dedicated user''' for this database and '''assign a password'''.
Create a '''dedicated user''' for this database and '''assign a password'''.
Line 145: Line 153:
Write this password down, you will need it later to configure the wiki.
Write this password down, you will need it later to configure the wiki.


('''Note''': replace "<USERNAME>" and "<SOMEPASSWORD>" with something else.)
('''Note''': replace "'''USERNAME'''" and "'''SOMEPASSWORD'''" with something else.)


  CREATE USER '<USERNAME>'@'localhost' IDENTIFIED BY '<SOMEPASSWORD>';
CREATE USER ''''USERNAME''''@'localhost' IDENTIFIED BY ''''SOMEPASSWORD'''';


Give this user '''the rights to edit the database''':
Give this user '''the rights to edit the database''':


  GRANT ALL PRIVILEGES ON <USERNAME>.* TO '<USERNAME>'@'localhost';  
GRANT ALL ON '''NAMEOFYOURDATABASE'''.* TO ''''USERNAME''''@'localhost' WITH GRANT OPTION;  


  FLUSH PRIVILEGES;
Check if it worked:
 
SHOW GRANTS FOR ''''USERNAME''''@'localhost';


Exit MariaDB:
Exit MariaDB:
Line 178: Line 188:


Try it out by opening your wiki: https://hub.xpub.nl/soupboat/wiki/
Try it out by opening your wiki: https://hub.xpub.nl/soupboat/wiki/
Point your browser to the URL of your wiki, and see if it works!
<span style="color:red;">NOTE: <code>Special:Version</code> is a useful page to see the metadat of your wiki!</span>




Line 194: Line 208:
== Enable uploads ==
== Enable uploads ==


Enable uploads in your LocalSettings.php:
Enable uploads in your '''LocalSettings.php''':


  $wgEnableUploads = true; # Enable uploads
$wgEnableUploads = true; # Enable uploads


and change permissions of the images folder:
and change permissions of the images folder:
Line 204: Line 218:


From: https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads
From: https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads
== Change upload size ==


You can change the upload size limit in the '''php.ini''' file (this is the configuration file for php).
You can change the upload size limit in the '''php.ini''' file (this is the configuration file for php).
Line 217: Line 233:
Search for <code>upload_max_filesize</code> and <code>post_max_size</code> and change the values to your desired upload size, for example to: <code>32M</code>
Search for <code>upload_max_filesize</code> and <code>post_max_size</code> and change the values to your desired upload size, for example to: <code>32M</code>


== Configure ==
Since we're running php through fpm, we need to restart the php-fpm service to apply these changes.
 
Check which version you are running:
 
$ sudo service --status-all
 
Then restart the service, replace "X" with the version number you are using:
 
$ sudo service php7.X-fpm restart
 
Next to this, you also need to configure the upload size in your <code>LocalSettings.php</code> file, add the following:
 
[SOON]
 
Try to upload a file to see if it works.
 
== Who is editing? ==


How open/closed do you want your wiki to be?
How open/closed do you want your wiki to be?
Line 224: Line 256:
* public, only people with accounts can edit, account creation is open
* public, only people with accounts can edit, account creation is open
* public, only people with accounts can edit, account creation is closed
* public, only people with accounts can edit, account creation is closed
* non-public, only you can edit  
* non-public, only you can edit


...
== Back up your wiki ==


== Back up your wiki ==
You can make a copy of the wiki's database with <code>mysqldump</code>:
 
$ mysqldump -u DBUSER DBNAME > DBNAME.sql
 
Next to the database, you will also need to back up:
 
* <code>LocalSettings.php</code>
* <code>images/</code>
* <code>extension/</code>
 
You can '''compress''' these files into one <code>.tar</code> file:
 
$ tar -czvf backup.tar.gz DBNAME.sql LocalSettings.php images extensions
 
This is your back up now, you can move it to a safe place, for example another computer/hard drive/usb stick/...
 
When you need the files, you can '''extract''' this tar file again with:


...
$ tar -xzvf backup.tar.gz


== Extensions ==
== Extensions ==
Line 287: Line 335:
* [[Setting up a mediawiki instance on the sandbox]]
* [[Setting up a mediawiki instance on the sandbox]]
* [[User:Rita_Graca/trimester6/technicaldocumentation#Installing_Mediawiki_on_the_pi | Rita's Notes]]
* [[User:Rita_Graca/trimester6/technicaldocumentation#Installing_Mediawiki_on_the_pi | Rita's Notes]]
* https://pad.xpub.nl/p/mediawiki-install-party
* https://pad.xpub.nl/p/mediawiki-install-party (MediaWiki install party in 2021)
 
[[Category:MediaWiki]]

Latest revision as of 12:13, 20 September 2024

Setting up your own Mediawiki.

Which wiki?

There are many different kinds of wiki softwares around: https://en.wikipedia.org/wiki/List_of_wiki_software

For this page we will focus on installing MediaWiki.

https://www.mediawiki.org/

Where is your wiki?

click and install

Most regular web hosting companies allow for installing MediaWiki without too much trouble, although maintaining and upgrading the code would still in most cases be up to you.

"wiki-family" or "wiki farm"

If you want to run a MediaWiki wiki and don't want to maintain your own infrastructure, you might be interested in a wiki-family or wiki farm.

One of those wiki hosting providers is Fandom (earlier called Wikicities and Wikia), see: https://www.fandom.com/

For more information and a list of wiki farms see: https://www.mediawiki.org/wiki/Hosting_services

on your own server

If you want to install a wiki on your own server, you can follow the steps on this page.

For notes on how to choose what kind of server you would like to work with and how to install it, see: https://pad.xpub.nl/p/hosting-and-serving

Dependencies

Mediawiki requires 3 things to be installed:

  • PHP
  • webserver (like nginx or apache)
  • database (MariaDB, MySQL, SQLite or PostgreSQL)

Check the Mediawiki download page to see which exact versions you need:

https://www.mediawiki.org/wiki/Manual:Installation_requirements

Install a database

For this example we will use MariaDB.

$ sudo apt install mariadb-server

Install a webserver

For this example we will use nginx.

$ sudo apt install nginx

Install PHP

Install PHP + the fpm and php-mysql extension:

$ sudo apt install php php-common php-fpm php-mysql php-mbstring php-xml php-intl

Configure your webserver to work with the fpm extension.

For example, when you work with nginx, edit the default config file with:

$ sudo nano /etc/nginx/sites-enabled/default

and add the following snippet:

Note: change the version number of php to your installed version!

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

First test if the nginx if oke:

sudo nginx -t 

And now reload nginx to apply the changes you made to this config file:

$ sudo service nginx reload

To see if php works now, you can make a php file in /var/www/html/ called test.php:

<?php 

phpinfo();

?>

Now open this file in the browser and see if it works.

Download Mediawiki

Navigate to the folder where you want to install Mediawiki.

In this example we will install it at /var/www/wiki/:

cd /var/www/wiki/

Download the latest version of Mediawiki and unzip the tar file.

You can copy the link from the Mediawiki download page: https://www.mediawiki.org/wiki/Download

wget https://releases.wikimedia.org/mediawiki/1.38/mediawiki-1.38.4.tar.gz
tar xf mediawiki-1.38.4.tar.gz

Rename the wiki folder something short, like "wiki".

mv mediawiki-1.38.4 wiki

Configure the URL

To connect the folder /var/www/wiki/ to an url like https://hub.xpub.nl/soupboat/wiki/ we need to edit the configuration file of the webserver.

$ sudo nano /etc/nginx/sites-enabled/default

Add the following lines:

location /wiki {
    alias /var/www/wiki/;
    index index.php;
}

See if it works: https://hub.xpub.nl/soupboat/wiki/

Database

By default you can log in to MariaDB with the root user and the root password.

However, it's a *good idea* to create a dedicated database + database user for your wiki. In this way you can easily back it up (and eventually restore it) with a simple mysqldump command. Also, it helps to keep different projects separate from each other. See the Mysql page on how to do this. Once you do this add the database name, user name, and password to the Mediawiki setup page when requested.

We will now make a dedicated database for your wiki.

First log in into MariaDB as root:

$ sudo mysql -u root 

Create a new database:

(Note: replace "NAMEOFYOURDATABASE" with the name of your wiki, for example: mywiki.)

CREATE DATABASE NAMEOFYOURDATABASE;

Create a dedicated user for this database and assign a password.

Write this password down, you will need it later to configure the wiki.

(Note: replace "USERNAME" and "SOMEPASSWORD" with something else.)

CREATE USER 'USERNAME'@'localhost' IDENTIFIED BY 'SOMEPASSWORD';

Give this user the rights to edit the database:

GRANT ALL ON NAMEOFYOURDATABASE.* TO 'USERNAME'@'localhost' WITH GRANT OPTION; 

Check if it worked:

SHOW GRANTS FOR 'USERNAME'@'localhost';

Exit MariaDB:

 quit

Setup your Mediawiki

Now go to the wiki setup script: https://hub.xpub.nl/soupboat/wiki/

(Or wherever you installed your wiki of course!)

In step 2 you can use your database settings as configured in the above step. The database prefix can be left empty.

Give the wiki a name and fill in the administrator account info. When in doubt, leave things at the default values.

At the end, download the LocalSettings.php file.

Upload LocalSettings.php

Upload the LocalSettings.php file you just downloaded to the folder of your wiki: /var/www/wiki/.

The wiki should work now!

Try it out by opening your wiki: https://hub.xpub.nl/soupboat/wiki/

Point your browser to the URL of your wiki, and see if it works!

NOTE: Special:Version is a useful page to see the metadat of your wiki!


When installing the wiki on a sandbox server

However for a sandbox server you have to tweak one line in the LocalSettings.php file.

Open the file with a text editor (like nano) and look for:

 $wgScriptPath = "/wiki";

and change it to:

 $wgScriptPath = "/soupboat/wiki";

Enable uploads

Enable uploads in your LocalSettings.php:

$wgEnableUploads = true; # Enable uploads

and change permissions of the images folder:

$ sudo chgrp www-data /var/www/wiki/images
$ sudo chmod 775 /var/www/wiki/images

From: https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads

Change upload size

You can change the upload size limit in the php.ini file (this is the configuration file for php).

See where it is at the server with:

$ php --ini

Open the php.ini file with nano:

$ sudo nano /path/to/file/php.ini

Search for upload_max_filesize and post_max_size and change the values to your desired upload size, for example to: 32M

Since we're running php through fpm, we need to restart the php-fpm service to apply these changes.

Check which version you are running:

$ sudo service --status-all

Then restart the service, replace "X" with the version number you are using:

$ sudo service php7.X-fpm restart

Next to this, you also need to configure the upload size in your LocalSettings.php file, add the following:

[SOON]

Try to upload a file to see if it works.

Who is editing?

How open/closed do you want your wiki to be?

  • public, everyone can edit
  • public, only people with accounts can edit, account creation is open
  • public, only people with accounts can edit, account creation is closed
  • non-public, only you can edit

Back up your wiki

You can make a copy of the wiki's database with mysqldump:

$ mysqldump -u DBUSER DBNAME > DBNAME.sql

Next to the database, you will also need to back up:

  • LocalSettings.php
  • images/
  • extension/

You can compress these files into one .tar file:

$ tar -czvf backup.tar.gz DBNAME.sql LocalSettings.php images extensions

This is your back up now, you can move it to a safe place, for example another computer/hard drive/usb stick/...

When you need the files, you can extract this tar file again with:

$ tar -xzvf backup.tar.gz

Extensions

You can find lists of extensions on the MediaWiki wiki: https://www.mediawiki.org/wiki/Category:Extensions

There are instructions on the MediaWiki page of the extension about the installations.

But basically you follow the following steps.

Copy the extension to:

/var/www/wiki/extensions

And then activate it in your LocalSettings.php:

/var/www/wiki/extensions/LocalSettings.php

with the following line:

wfLoadExtension( 'NAMEOFYOUREXTENSION' );

If it is installed correctly, it should show up on this page:

URL-TO-YOUR-WIKI/Special:Version

Customizing

Choose a skin

See: https://www.mediawiki.org/wiki/Category:All_skins + https://skins.wmflabs.org/#/explore

You can find instructions regarding how to install the skin on the MediaWiki page for the skin, for example this is the page for the Vector skin: https://www.mediawiki.org/wiki/Skin:Vector

Tweaking the skin

You can edit the CSS of the skin at this wiki page: MediaWiki:Common.css

And leave javascript code here: MediaWiki:Common.js

Customize text and menu's

Edit the menu: MediaWiki:Sidebar

Edit system texts: https://www.mediawiki.org/wiki/Help:System_message

You can find all system texts at:

Special:AllMessages

See also