MediaWiki Extensions Tutorial
How to install and manage extensions in MediaWiki
Extensions are used to add some options or functionalities to your MediaWiki that are not included in the core options that come with the application. There are many different extensions for all sorts of things. It's recommended that you install and use only extensions that you need. If you have too many extensions, the site becomes more difficult to maintain, and it may also become more vulnerable in terms of security.
MediaWiki comes prepackaged with some extensions. During the installation of MediaWiki you can choose which ones you want to be enabled. By default, they are all disabled. If you want to, you can enable/disable them at any time after the installation is complete.
In this tutorial we'll explain how to install and enable extensions, and respectively how to disable and uninstall them. This is generally done in the same way for most extensions. For some extensions you may need to perform some additional tasks, or the installation procedure might be different, so you should always check the information about the particular extension.
We'll show you:
- how to install extensions
- how to enable and disable extensions
- how to uninstall extensions
- how to upgrade extensions
As we mentioned, most extensions are installed in the same way. It's described in this section. Some extensions however may have some additional requirements.
Basically, you have to download the extension and put it in the correct location on your hosting account. Enabling the extension can also be considered part of the installation process; we've included that in the next section of this tutorial.
So to install an extension you have to:
- Download the extensions. After you find the extension that you want, download it on your local computer. On the official MediaWiki website there are a lot of extensions that you can download for free. You can check the alphabetical list with extensions on the official site, or you can go to the page where the extensions are grouped into categories according to their functions. In any case, from there you can go to the page of the extension on which you can find a link for downloading it, and you'll also find specific information about the extension, including any additional things that you need to know about its installation.
- After you download the extension you have to upload it on your MediaWiki hosting account in the /extensions folder. If, for example, the application is installed directly in the root web-accessible public_html directory on your hosting account (making the frontend accessible at yourdomain.com), then you have to upload the extension in public_html/extensions. The files and folders of the extension have to be put in a subfolder inside the /extensions folder. Normally, this subfolder is labeled with the name of the extension (e.g. public_html/extensions/name-of-extension where you have to replace name-of-extension with the actual name of the extension).
In the /extensions directory of your MediaWiki you'll find the folders of the extensions that come prepackaged with the application. To use any of them you only have to enable it as described in the next section.
The files of the extension that you download on your local computer are packed into an archive. You can then unpack that archive on your local computer and upload the unpacked content on your hosting account, or you can first upload the archive on your account and unpack it there. If you unpack it on your local computer, a folder with the name of the extension will be automatically created. Inside that folder are the files of the extension. You have to upload that folder with its content into the MediaWiki /extensions directory on your hosting account.
If you decide to upload the archive and then unpack it on the account, you should first create a folder with the extension's name in the /extensions directory on your account, then upload the archive in that newly created folder and unpack it.
Whatever you do you should end up in the /extensions directory on the account with a subfolder labeled with the name of the extension, and that subfolder should contain the files of the extension. For example, if your MediaWiki is installed directly in the public_html directory on the account and you want to install the BreadCrumbs extension, you can create a folder BreadCrumbs (or just breadcrumbs) in public_html/extensions and put the content of the extension in public_html/extensions/BreadCrumbs. Inside that BreadCrumbs folder should be the main PHP file of the extension labeled BreadCrumbs.php; the main PHP file for every extension is by default labeled with the name of the extension. You'll need the name of the extension's folder and its main PHP file later when you enable the extension.
There are a few ways you can upload the extension, and also, if necessary, to create a folder on the hosting account for the extension and unpack the archive with the content of the extension:
- You can upload files and folders with an FTP client (e.g. FileZilla). In our FTP tutorials you'll find details on how to configure some FTP clients.
- HostKnox clients can upload files, create folders and unpack archives on their accounts from the Files section of the HostKnox control panel. For more information check out the tutorial on how to manage files with the file manager of the HostKnox control panel.
- Another possibility is to do it via SSH. All HostKnox clients have access to their accounts via SSH. For more information on how to connect via SSH check out the tutorial on how to connect to your hosting account via SSH (for Windows users). You'll also find information on how to perform various tasks via SSH in the SSH section of our knowledgebase.
In order for an extension to function and for you to be able to use its options on the site, it has to be enabled by inserting a line with code in the LocalSettings.php file of your MediaWiki. The file is in the root MediaWiki folder on the hosting account, so if, for example, the application is installed directly in the public_html directory on the account, the path to the file will be public_html/LocalSettings.php.
At the end of the file add the following line:
You have to replace name-of-extension with the name of the folder that contains the files of the extension, and you have to replace name-of-extension.php with the name of the main PHP file of the extension (it's labeled with the name of the extension and is located directly inside the folder of the extension). All extension are located inside the /extensions directory of your MediaWiki. If we use the example with the BreadCrumbs extension from the previous section, the line will look like: require_once "$IP/extensions/BreadCrumbs/BreadCrumbs.php";.
If you want to disable the extension, simply delete the corresponding line in LocalSettings.php, or comment it by putting the symbol # in front of it.
Uninstalling an extension is simple. Remove its line from the LocalSettings.php file of your MediaWiki. If you're not sure what that line is, check the previous section of this tutorial for more information.
Then delete the the folder of the extension from the /extensions directory of your MediaWiki.
Note that for some extensions you may need to do some additional modifications when you install them; so when you uninstall such an extension you may have to undo these modifications.
Sometimes newer versions of existing extensions are released. This is done to fix known problems and bugs, to improve the extension, or to make it compatible with newer MediaWiki versions. When there's a newer release for one of your installed extensions, this doesn't necessarily mean that you have to update it, but sometimes you may have to do it.
To update an extension:
- Download the newer version of the extension. You can find a link either on the page of the extension on the MediaWiki site (or from the developer's website, if there's one).
- Upload the extension on your hosting account in the directory of the extension that you want to update, and replace the old files with the new ones. For example, if your MediaWiki is installed directly in the public_html directory on your hosting account and the extension that you want to update is called BreadCrumbs, then you have to upload the files of the new version of the extension in public_html/extensions/BreadCrumbs and overwrite the old files.
- In some cases you may also need to update the database. You can do this either via SSH or you can do it with a web-browser. To do it with a web-browser, assuming that the homepage of your site is yourdomain.com, then open the URL address yourdomain.com/mw-config and follow the instructions that appear on the screen.
In some rare cases you may need to perform some additional tasks. This depends on the particular extension. You should check the information about that extension to see if you have to do something else.