MediaWiki — Installing and more – DreamHost Knowledge Base

MediaWiki — Installing and more

 

Overview

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 can be manually installed on DreamHost servers.

Before you install MediaWiki

Use these instructions to prepare your website for the MediaWiki installation:

  1. Download MediaWiki from its website at:
  2. Create a database that will be used by MediaWiki. View the following article for further information:
  3. Set your domain to use PHP 8.1 or higher. View the following articles for further information:

Installing MediaWiki

You can find detailed instructions on manually installing MediaWiki in the following article:

  1. Upload the MediaWiki file that you downloaded to your web server via FTP.
  2. Log into your server via SSH, then decompress the file on the server.
  3. Confirm that the MediaWiki files are in your domain’s web directory. You may need to copy them from a newly-created mediawiki-x.xx.x directory to the root directory.
  4. Point your browser to mw-config/index.php in your extracted MediaWiki files, which opens the setup screen. For example:
    • http://example.com/mw-config/index.php
  5. Follow the on-screen instructions to complete the process.
    Once the installation process completes, a LocalSettings.php file is downloaded in your browser.
  6. Upload the LocalSettings.php file to your MediaWiki install folder on the webserver via FTP.

The LocalSettings.php file contains the configuration settings for your new MediaWiki installation, such as database credentials and user permissions.

Common add-ons to MediaWiki

Extensions

MediaWiki offers many different types of extensions that 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 create a Shell (SSH) user 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 full path to the version on the server. View the following article for examples:

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:

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 the following DreamHost article for further instructions:

Secure settings

Passwords and HTTPS

MediaWiki 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 add an SSL certificate.

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/username/external_includes/database_info.php
    Make sure to change username to your Shell user. 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/username/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.

Upgrading MediaWiki

Always make sure to first backup your database and website files before making any adjustments. This way, if something were to error you could quickly replace your files. View the following article for details:

View the following guide at mediawiki.org for upgrade instructions:

It may be necessary to run the /maintenance/update.php script after upgrading. To do so, log into your site via SSH. Then run the following command:

[server]$ php /maintenance/update.php

This runs an update script that should fix any current errors on your site. If that doesn't work, specify the full path to a version of PHP. For example:

[server]$ /usr/local/php81/bin/php maintenance/update.php

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 installation, 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

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?