Install Mediawiki: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Setting up your own Mediawiki. | |||
==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/Download#System_Requirements | |||
===Install a database=== | |||
For this example we will use <code>MariaDB</code>. | |||
$ sudo apt install mariadb-server | |||
===Install a webserver=== | |||
For this example we will use <code>nginx</code>. | |||
$ sudo apt install nginx | |||
===Install PHP=== | |||
Install <code>PHP</code> + the <code>fpm</code> extension: <code>$ sudo apt install php php-common php-fpm</code> | |||
Configure your webserver to work with the <code>fpm</code> extension. | |||
For example, when you work with nginx, edit the default config file with: | |||
$ sudo nano /etc/nginx/sites-enabled/default.conf | |||
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; | |||
} | |||
==Download Mediawiki== | |||
Navigate to the folder where you want to install Mediawiki. | |||
In this example we will install it at <code>/var/www/wiki/</code>: | |||
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.35.1 wiki | |||
== Configure the URL == | |||
To connect the folder <code>/var/www/wiki/</code> to an url like <code>https://hub.xpub.nl/soupboat/wiki/</code> we need to edit the configuration file of the webserver. | |||
$ sudo nano /etc/nginx/sites-enables/default.conf | |||
Add the following lines: | |||
location /wiki { | |||
alias /var/www/wiki/; | |||
index index.php; | |||
} | |||
See if it works: https://hub.xpub.nl/soupboat/wiki/ | |||
== Database == | == 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 <code>mysqldump</code> 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 -p | |||
Create a '''new database''': | |||
('''Note''': replace "<NAMEOFYOURWIKI>" with the name of your wiki, for example: mywiki.) | |||
CREATE DATABASE <NAMEOFYOURWIKI>; | |||
Create a '''dedicated user''' for this database and '''assign a password''': | |||
('''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 PRIVILEGES ON <USERNAME>.* TO '<USERNAME>'@'localhost'; | |||
FLUSH PRIVILEGES; | |||
Exit MariaDB: | |||
quit | |||
== Uploads == | == Uploads == | ||
https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads | https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads |
Revision as of 15:03, 1 November 2022
Setting up your own Mediawiki.
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/Download#System_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
extension: $ sudo apt install php php-common php-fpm
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.conf
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; }
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.35.1 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-enables/default.conf
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 -p
Create a new database:
(Note: replace "<NAMEOFYOURWIKI>" with the name of your wiki, for example: mywiki.)
CREATE DATABASE <NAMEOFYOURWIKI>;
Create a dedicated user for this database and assign a password:
(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 PRIVILEGES ON <USERNAME>.* TO '<USERNAME>'@'localhost';
FLUSH PRIVILEGES;
Exit MariaDB:
quit
Uploads
https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads