# Media Wiki

[Debian / Ubuntu packages](https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu)

[Download and install](https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki)

[UI config with browser](https://www.mediawiki.org/wiki/Manual:Config_script)

[LocalSettings.php guide](https://www.mediawiki.org/wiki/Manual:LocalSettings.php)

## Config

### Tweak MediaWiki

File at `/var/lib/mediawiki/LocalSettings.php`

### Look at postgresql tables

When logged as *wiki_app*, use command `\\dt mediawiki.*`

## Warning

Do not use wiki in url filepath.

## Install Media Wiki

### PostgreSQL

Install profile, used during the installation phase :
```
CREATE USER install WITH SUPERUSER PASSWORD '1eh87x2_tt';
```

Wiki profile :

```
sudo -u postgres psql

CREATE USER wiki_app WITH NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '52w7maa';

CREATE DATABASE wiki_db WITH OWNER wiki_app;
```

### GNU/Linux packages

Minimal :
```
sudo apt install apache2 php libapache2-mod-php php-xml php-mbstring
```

Optimal :
```
sudo apt install php-apcu php-intl php-gd php-cli php-curl
```

If php-apcu :
`sudo service apache2 reload`


### Download

```
cd /tmp/

wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz

tar -xvzf /tmp/mediawiki-1.33.0.tar.gz

sudo mkdir /var/www/mediawiki

sudo mv mediawiki-*/* /var/www/mediawiki

sudo chown -R www-data:www-data /var/www/mediawiki

```

### Cli config

This config is very difficult to handle. It is much easier to use the configuration with browser.

```
php maintenance/install.php
```

### Configuration with browser

Make the folder `/var/www/mediawiki` served by _httpd_.

Then open the url : `http://domain.com/mw-config`

At the end, you have to download the `LocalConfig.php` file.

Put it in the folder `/var/www/mediawiki`.

BEWARE : if you have enabled the accelerated cache, you have to add this line to the `LocalConfig.php` file :

```
$wgSessionCacheType = CACHE_DB;
```

Note : if you don't, the wiki can work but it would be impossible to log in or to create any account.

### Apache HTTPS

_todo_

### Optional : configure PHP

_todo_

## Extensions

### Draw.io

[Extension:DrawioEditor](https://www.mediawiki.org/wiki/Extension:DrawioEditor)

```
cd /var/www/mediawiki/extensions/

sudo git clone https://github.com/mgeb/mediawiki-drawio-editor DrawioEditor

sudo git clone https://github.com/p12tic/NativeSvgHandler.git
```

**Fix SVG upload** : add `http://www.w3.org/1999/xhtml` in `/var/www/mediawiki/includes/upload/UploadBase.php`.

## Uninstall Mediawiki

### Disable site

Required to disable database connection :

```
sudo a2dissite 'wiki.*'

sudo service apache2 reload
```

### Drop postgreSQL stuff

As _postgres_ user :

```
DROP DATABASE wiki_db ;

DROP ROLE wiki_app ;
```

### Delete web server files

```
sudo rm -r /var/www/mediawiki
```

## Backup Wiki

[https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki](Backing up a wiki)

See the `ServerScripts/Backup` folder.
