MediaWiki
MediaWiki is a free and open source wiki software written in PHP, originally developed for Wikipedia. It also powers this wiki (see Special:Version and the GitHub repository).
Installation
To run MediaWiki you need three things:
- the mediawiki package, which pulls in PHP
- a web server, such as Apache HTTP Server, nginx or lighttpd
- a database system – one of MariaDB, PostgreSQL, SQLite or MySQL
To install MediaWiki on XAMPP, see mw:Manual:Installing MediaWiki on XAMPP
Configuration
The steps to achieve a working MediaWiki configuration involve editing the PHP settings and adding the MediaWiki configuration snippets.
PHP
MediaWiki requires the iconv extension, so you need to uncomment extension=iconv in /etc/php7/php.ini.
Optional dependencies:
- For thumbnail rendering, install either ImageMagick or php7-gd. If you choose the latter, you also need to uncomment
extension=gd. - For more efficient Unicode normalization, install php7-intl and uncomment
extension=intl.
Enable the API for your DBMS:
- If you use MariaDB, uncomment
extension=mysqli. - If you use PostgreSQL, install and uncomment .
- If you use SQLite, install and uncomment .
Second, tweak the session handling or you might get a fatal error () by finding the session.save_path path. A good choice can be /var/lib/php/sessions or .
You will need to create the directory if it does not exist and then restrict its permissions:
# mkdir -p /var/lib/php/sessions/ # chown http:http /var/lib/php/sessions # chmod go-rwx /var/lib/php/sessions
If you use PHP's open_basedir and want to allow file uploads, you need to include (mediawiki symlinks to ).
Apache
Follow Apache HTTP Server#PHP.
Copy to and edit it as needed.
Add the following line to :
Include conf/extra/mediawiki.conf
Restart the daemon.
Nginx
To get MediaWiki working with Nginx, create the following file:
/etc/nginx/mediawiki.conf
location / {
index index.php;
try_files $uri $uri/ @mediawiki;
}
location @mediawiki {
rewrite ^/(.*)$ /index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm7/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri @mediawiki;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
# Restrictions based on the .htaccess files
location ~ ^/(cache|includes|maintenance|languages|serialized|tests|images/deleted)/ {
deny all;
}
location ~ ^/(bin|docs|extensions|includes|maintenance|mw-config|resources|serialized|tests)/ {
internal;
}
location ^~ /images/ {
try_files $uri /index.php;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location /rest.php {
try_files $uri $uri/ /rest.php?$args;
}
Ensure that is installed and is started.
Include a server directive, similar to this
Finally, restart and daemons.
Lighttpd
You should have Lighttpd installed and configured. "mod_alias" and "mod_rewrite" in server.modules array of lighttpd is required. Append to the lighttpd configuration file the following lines
Restart the daemon.
Database
Set up a database server as explained in the article of your DBMS: MariaDB, PostgreSQL, SQLite or MySQL.
If you have set a non-empty root password for the database server, MediaWiki can automatically create the database during the next step. (See MariaDB#Reset the root password for how to set this password retrospectively for MariaDB.) Otherwise the database needs to be created manually - see upstream instructions.
LocalSettings.php
Open the wiki URL (usually http://your_server/mediawiki/index.php) in a browser and do the initial configuration. Follow upstream instructions.
The generated file is offered for download, save it to and create symbolic link to it from :
# ln -s /etc/webapps/mediawiki/LocalSettings.php /usr/share/webapps/mediawiki/LocalSettings.php
This file defines the specific settings of your wiki. Whenever you upgrade the mediawiki package, it will not be replaced.
Upgrading
See mw:Manual:Upgrading, and do not forget to run:
# cd /usr/share/webapps/mediawiki # php maintenance/update.php
Tips and tricks
Mathematics (texvc)
Usually installing texvc and enabling it in the configuration is enough:
$wgUseTeX = true;
If you get problems, try to increase limits for shell commands:
Unicode
Check that PHP, Apache HTTP Server and MariaDB all use UTF-8. Otherwise you may face strange bugs because of encoding mismatch.
VisualEditor
The VisualEditor MediaWiki extension provides a rich-text editor for MediaWiki. Follow mw:Extension:VisualEditor to install it.
You will also need the Parsoid Node.js backend, which is available in .
Adjust the path to MediaWiki in :
parsoidConfig.setInterwiki( 'localhost', 'http://localhost/mediawiki/api.php' );
After that enable and start .
Alternatively, one may also use the package, and configure the service via the yaml file, where the following lines should be present:
The matching part in the mediawiki settings:
/etc/webapps/mediawiki/LocalSettings.php
$wgVirtualRestConfig['modules']['parsoid'] = array( // URL to the Parsoid instance - use port 8142 if you use the Debian package - the parameter 'URL' was first used but is now deprecated (string) 'url' => 'http://localhost:8000/', // Parsoid "domain" (string, optional) - MediaWiki >= 1.26 'domain' => 'localhost', // Parsoid "prefix" (string, optional) - deprecated since MediaWiki 1.26, use 'domain' 'prefix' => 'localhost', // Forward cookies in the case of private wikis (string or false, optional) 'forwardCookies' => false, // request timeout in seconds (integer or null, optional) 'timeout' => null, // Parsoid HTTP proxy (string or null, optional) 'HTTPProxy' => null, // whether to parse URL as if they were meant for RESTBase (boolean or null, optional) 'restbaseCompat' => null, );
After configuration, the service may be started (restarted) and (if not done yet) enabled.