MediaWiki overview

Mediawiki.fw.png

MediaWiki is free, open-source software you can use to create wiki content, such as Wikipedia. The application is ideal for creating knowledge base pages similar to an encyclopedia.

For more information, visit MediaWiki's official site:

MediaWiki is offered as a One-Click Install in your DreamHost panel.

Installing MediaWiki

The simplest way to install MediaWiki is to use the One-Click Install feature in your panel which installs the software for you.

The other option is to install it manually which requires you to download the files yourself and upload them to your web server.

Detailed instructions on manually installing MediaWiki are provided in the following article:

Both installation methods install the same files and configurations. However, if you choose to install MediaWiki manually, you have the option to install the latest version of MediaWiki which DreamHost does not currently offer in the panel.

Common add-ons to MediaWiki

Extensions

MediaWiki offers many different types of extensions which you can use to add further functionality and customization to your site. See the following article for further details:

Google Analytics

You can also add Google Analytics to your MediaWiki installation if you wish. See the following article for detailed instructions:

Handling images

Thumbnail problems

MediaWiki can occasionally have problems generating image thumbnails, such as returning corrupted images or the error message "Error creating thumbnail". A common cause of this is not enough memory.

If you upload a large image and see "Error creating thumbnail" where a thumbnail should be, try adding the following to your LocalSettings.php file in your site’s primary directory:

$wgMaxShellMemory = 524288;

SVG images

For best results in generating thumbnails of SVG images, you may wish to install librsvg.

The SVG installation process is not supported and is recommended only for advanced users. See the following article for more information:

Email and spam

Domain spoofing

Add the following to your LocalSettings.php file:

$wgUserEmailUseReplyTo = true;

This spoofs the domain so that the sending user's email is in a Reply-To header instead of the From header. Otherwise, the email that users try to send each other through Special:EmailUser on your wiki cannot be delivered.

Notifications

Given the SMTP quota, you need to be careful if you enable $wgEnotifWatchlist.

If a page is 'watchlisted' by 100 users who have that user preference enabled, then a change to that page uses up your quota for an hour, if you are on shared hosting.

Blocking MediaWiki spam

Combating SPAM
Provides steps you can take to combat SPAM on your website.
MediaWiki Wiki Spam
Description of what wiki spam is, and instructions on how any user can help tackle the wiki-spam problem (not just administrators). Not all of which is obvious, so it's worthwhile for administrators to read through this too, as you might wish to refer your wiki users to this.
CAPTCHA
Enabling a Captcha on any form helps to reduce spam.
Restrict account creation
By default, anyone can create an account on your wiki. However, you can restrict who has the ability to create accounts.
User rights
You also have control over user rights. You can disable non-user edits with this feature.

MediaWiki utilities

Maintenance scripts

In the MediaWiki root install, there is a subdirectory named /maintenance which includes various scripts you can run on your MediaWiki installation. In order to run the PHP scripts, you must enable shell access on your domain.

In order to run the scripts, you must enter ‘php’ before the filename. For example, run the following command if you wish to run the script eval.php in the maintenance directory:

[server]$ php eval.php

If you simply type ‘php’, it uses the default version on the server. However, you can explicitly choose any version by using the following instead:

  • /usr/local/php55/bin/php
  • /usr/local/php56/bin/php
  • /usr/local/php70/bin/php

To learn more about the individual scripts, see the following article:

Caching

Caching your site can improve performance. There are several ways to cache your data using MediaWiki. See the following articles for further information:

Unicode normalization

To use the intl PECL extension for Unicode normalization, follow this guide on creating a phprc file. Once added, you can add the following line to it:

extension = intl.so

Enabling uploads

See the following guide for instructions on how to enable file uploads:

Backing up

See the following guide for instructions on how to back up your data:

Also, see following DreamHost article for further instructions:

Secure settings

Passwords and HTTPS

The One-Click Install uses a form on an HTTP web page to take your password. This means that your password transmits over the network in clear text. To use HTTPS, you must enable Secure Hosting. Once an SSL certificate is added to your domain, you can force HTTPS in any request by adding code to a configuration file. See the following articles for further details depending on if your site is running on an Apache or Nginx server:

LocalSettings.php permissions

The LocalSettings.php file stores your database login information in it, including the database username and password. After you move the LocalSettings.php file to your root directory, you can review its permissions.

You should update the permissions on that file to 640 or 600. This can be done by running the following command:

[server]$ chmod 640 LocalSettings.php

This makes the file only writeable for the owner while the group can still read it. However, the most secure option is to mark the file as only readable/writable by the owner:

[server]$ chmod 600 LocalSettings.php

This way, your MySQL password on this file is safe from viewing from other users on the same server. See the following article for further details on permissions:

Moving database credentials to another file

Another good security practice is to set up a separate PHP file stored in your user's directory. This file stores your credentials and instead passes them as variables. The following setup describes how to link your LocalSettings.php file to this new file:

  1. In your user's directory (not the domain's directory), create a new directory called "external_includes".
  2. In this new folder, create a file called "database_info.php".
    The full path to this new file is:
    /home/[yourusername]/external_includes/database_info.php
    The file includes the following (fill in your true values within the quotes):
    <?php
     $database_server = "mysql.example.com"; 
     $database_name   = "databasename"; 
     $database_user   = "username";
     $database_pw     = "password";
     ?>
    
  3. Remove the current database credentials in your LocalSettings.php file.
  4. Replace those lines with the following:
    # enhanced DB security
     require_once ("/home/[yourusername]/external_includes/database_info.php");
     
     $wgDBserver     = $database_server;
     $wgDBname       = $database_name;
     $wgDBuser       = $database_user;
     $wgDBpassword   = $database_pw;
     
     # DB variables not security related - leave these alone from how when you set up your wiki
     $wgDBprefix     = "wiki_";
     $wgDBtype       = "mysql";
    

With this setup, your credentials in the LocalSettings file are now safely hidden.

Licensing settings

You can select which MediaWiki license you wish to use. See the following article for more details:

Wikipedia uses GFDL. If you wish to enable reusable content in Wikipedia and other GFDL projects, then you must use GFDL (or multi-license to use both). In general, if there are other projects you want to work with, you should use compatible licensing.

Advanced settings and troubleshooting

Enable debugging

You can enable debugging by adding lines at the bottom of your LocalSettings.php file. By enabling this, you are provided detailed debugging information to help isolate the cause.

See the following article for further details:

After you finish troubleshooting your install, you should disable your debugging settings.

Short URLs

You can shorten the URLs to appear more user friendly. For example, you can change the following URL example:

example.com/w/index.php?title=Main_Page

to

example.com/wiki/Main_Page

See the following articles for further instructions:

Fixing MediaWiki after adding an SSL certificate to a domain

You may notice that MediaWiki loads incorrectly or shows 'insecure content' warnings in the browser bar after you add an SSL certificate to the domain where MediaWiki is installed.

Your LocalSettings.php file must be edited to reflect HTTPS for your domain. To fix, find the $wgServer value in the LocalSettings.php file and make sure the domain shows HTTPS (and not HTTP) for the URL value:

## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://www.example.com";

After you make this edit, save it, and then transfer the LocalSettings.php file to the root wiki folder on your server. Refresh your browser and MediaWiki should load normally.

See also

Internal links

External links

 

Did this article answer your questions?

Article last updated PST.