Toggle navigation

MediaWiki Image Guide

Version 1.28.0

Websoft9 MediaWiki is a pre-configured, ready to run image for running MediaWiki on Alibaba Cloud.

MediaWiki is a free and open-source wiki software package written in PHP. It serves as the platform for Wikipedia and the other Wikimedia projects, used by hundreds of millions of people each month. MediaWiki is localised in over 350 languages and its reliability and robust feature set have earned it a large and vibrant community of third-party users and developers.

Software version: MediaWiki1.28.0
Software directory: /data/wwwroot/default/mediawiki

Basic software environment: Click here
PHP Configuration File: /usr/local/php/etc/php.ini
Virtual host Configuration File directory: /usr/local/apache/conf/vhost.sh
Virtual host Configuration Command: /root/oneinstack/vhost

Database install directory: /usr/local/mysql
Database data directory: /data/mysql
Database Configuration File: /etc/my.cnf

 

After the installation of Image,please verify it

  • Login on Alibaba Cloud console,get you Internet IP Address
  • Open you Chrome or Firefox on your local PC,visit the http://Internet IP Address/
  • If verify successfully,you can enter the boot page of Websoft9 below
  • If no response from browser,please check the Security Group settings to ensure that port 80 is been allowed

This Image use MySQL for database

#default user/password:root/123456

MySQL User Guide: Click here

We will show you how to install MediaWiki in this section:
1.Create the database required for MediaWiki,
2.Add a virtual host required for MediaWiki,
3.Start to install MediaWiki.

Step1. Create a database

1.login in MySQL:

Method 1:Use following URL to open phpMyAdmin page: http://< Public net IP >/phpMyAdmin

Method 2:Use SSH command to login in.

mysql -uroot –p                      #enter mysql console

 #default user/password:root/123456            More MySQL User Guide: Click here

 

2.create a database:

MySQL [(none)]> create database mydbname;

MySQL [(none)]> show databases;

 

3.Create a Database User and grants permissions to the User:

MySQL [(none)]> grant all privileges on mydbname.* to username@’localhost’ identified by ‘userpassword’;

MySQL [(none)]> flush privileges;

MySQL [(none)]> exit;

before2

Step2. Add a virtual host

Use SSH Command to Add a virtual host:

[root@iZbp1i4rjdsy216yq7lgucZ ~]# cd /root/oneinstack

[root@iZbp1i4rjdsy216yq7lgucZ oneinstack]# ./vhost.sh

Step3. Install MediaWiki

Open your domain name via browser:
1. Choose a language,Click “set up the wiki”;

2. Choose a language,Click “Continue”;

3. Click “Continue”;

4.Fill in database user, password and database name,Click “Continue”;

5. Set database character,Click “Continue”;

6.Set the site name, administrator account, password and mail,Click “Continue”;

7. Click “Continue”;

8. Click “Continue”;

9. Click “Continue”;

10. Download the file and upload it to the server directory:/data/wwwroot/default/mediawiki

OK, it has been installed successfully.

Use http://<domain name>/  to go to your index page.

Extensions let you customize how MediaWiki looks and works.Wiki users can browse through existing extensions or request a new extension. System administrators can install (or remove) extensions on the MediaWiki installations that they manage. Developers can write new extensions or improve or maintain existing extensions.

You can find all extension from /data/wwwroot/default/mediawiki/extensions

 

Installing an extension

MediaWiki is ready to accept extensions just after installation is finished. To add an extension follow these steps:

  1. Before you start
    Many extensions provide instructions designed for installation using unix commands. You require shell access (SSH) to enter these commands listed on the extension help pages.
  2. Download your extension.
    Extension Distributor helps you to select and download most of the popular extensions.
    Extensions are usually distributed as modular packages. They generally go in their own subdirectory of $IP/extensions/. A list of extensions stored in the Wikimedia Git repository is located at git:mediawiki/extensions. Some extensions don’t use version control and are not recommended.
    Some extensions are also available in bundlescomposer or package repositories.
  3. Install your extension..
    Generally, at the end of the LocalSettings.php file (but above the PHP end-of-code delimiter, “?>“, if present), the following line should be added:
    // mw.v 1.24.x or less
    require_once "$IP/extensions/extension_name/extension_name.php";
    // mw.v 1.25.x or above
    wfLoadExtension( '<extension-name>' );
    
    This line forces the PHP interpreter to read the extension file, and thereby make it accessible to MediaWiki.
    Some extensions can conflict with maintenance scripts, for example if they directly access $_SERVER (not recommended).
    In this case they can be wrapped in the conditional so maintenance scripts can still run.
//for mw.v 1.24.x or less
if (!$wgCommandLineMode) {
   require_once "$IP/extensions/extension_name/extension_name.php";
}
//for mw.v 1.25.x or above
if (!$wgCommandLineMode) {
   wfLoadExtension ( '<extension-name>' );
}
The maintenance script importDump.php will fail for any extension which requires customized namespaces which is included inside the conditional above such as Extension:Semantic MediaWikiExtension:Semantic Forms.

Note:

  • Ensure that required permissions are set for extensions!
  • While this installation procedure is sufficient for most extensions, some require a different installation procedure. Check your extension’s documentation for details.
  • If you want to alter configuration variables in LocalSettings.php, you have to do this typically after including the extension. Otherwise defaults defined in the extension will overwrite your settings.
  • While extension declaration can be placed in other places within the LocalSettings.php file, never place extensions before the require_once “includes/DefaultSettings.php”; line for MediaWiki versions below 1.17 . Doing so will blank the extension setup function arrays, causing no extensions to be installed, and probably will make your wiki inaccessible until you fix it!

Upgrading an extension

Some extensions require to be updated whenever you update MediaWiki, while others work with multiple versions. To upgrade to a new version of an extension:

  1. Download the new version of the extension
  2. Replace all the extension files in the extension/ExtensionName directory with the new files. Do not remove the extension configuration present in LocalSettings.php
  3. Depending on the extension, you may have to run the Update.php maintenance script. Most extensions will mention if this script needs to be run or not. (Running the update.php script when its unnecessary will not hurt anything, so if you’re unsure don’t be afraid to run it). If you don’t have command line access, you can also use the web updater.
  4. That’s all you need to do. In most cases any extension configuration you have in LocalSettings.php will also work with the newer version of the extension.

Note:These instructions cover 99% of extensions. If the specific extension you are upgrading has instructions that differ from these, you should probably follow the specific extension’s instructions

Uninstalling an extension

Extensions are added by adding a line to LocalSettings.php, which basically looks like this:

// mw.v 1.24.x or less
require_once 'extensions/extension_name/extension_name.php';
// mw.v 1.25.x or above
wfLoadExtension( '<extension-name>' );
Depending on the extension you want to uninstall additionally other stuff might be done on installation, which you want to undo now. For details see the section on installing an extension.
  1. Remove this line and the extension is uninstalled. If you want to, you can (and if you do not want to use this extension in the future you should) remove the files of this extension inside the folder “extensions/”.
  2. Maybe you also have some other lines in LocalSettings.php, which have to do with the extension you want to remove. Most likely this will be lines, which give certain users the right to access pages, which are provided by the extension. These lines contain the variable “$wgGroupPermissions” and make some settings there. As far as they have to do with rights, which come from the removed extension, you can remove these lines as well.
  3. Maybe your extension also has added columns to your database. The updater maintenance/update.php removes them, when you run it, after you have uninstalled the extension.

It is important to make regular backups of the data in your wiki. This page provides an overview of the backup process for a typical MediaWiki wiki; you will probably want to devise your own backup scripts or schedule to suit the size of your wiki and your individual needs.

Manual:Backing up a wiki

Manual:Restoring a wiki from backup

Run upgrading,follow these steps:

  1. Check the requirements
  2. Read the release notes
  3. Back up existing files and the database
  4. Unpack the new files
  5. Upgrade extensions
  6. Run the update script to check the database
  7. Test the updat

Read more:https://www.mediawiki.org/wiki/Manual:Upgrading

If you have installed MediaWiki,the installer has generated a LocalSettings.php file. It contains all your configuration.

You will need to download it and put it in the base of your wiki installation (the same directory as index.php). The download should have started automatically.

LocalSettings.php is a part of configuration of Mediawiki,you can see includes/DefaultSettings.php for all configurable settings.But if you make changes for DefaultSettings.php, they will be lost on next upgrade of MediaWiki!

Modify the  /usr/local/php/etc/php.ini file to increase the allowed size for uploads:

; Maximum size of POST data that PHP will accept.
post_max_size = 16M
; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

then,restart the apache

# service httpd restart

 

How to create a page?

There are several ways to create a new page:

  • Create a link to the page on another page, then click on the red link which appears
  • Browse to the intended location of the page, e.g. http://www.example.com/index.php?title=New_page and click on the “Edit“, “Create” or “Create source” link.

On some wikis, a failed search for a page will contain a link which allows you to edit that page.

See also: Help:Starting a new page

 

There have another effective method for creating new page.You may enter the name of a new page directly in the search field, and click the “Search” button and can choose Create this page of the results page. The new page will be named after your query.

How to edit a page?

It’s very easy to edit the contents of a wiki:

  1. Click the “Edit” page tab at the top of the page.
  2. Make changes to the text.
  3. Click the “Save page” button.

Visit the URL http://youdomin.com/mediawiki/mw-config/index.php?page=Restart&lastPage=Install

Enter the Restart Installation below:

When remaind you that you need  the UpgradeKey ,you can find $wgUpgradeKey in then  “LocalSettings.php” file

You shouldn’t edit the CSS files (such as common.less) directly, because it will make upgrading harder if you need to apply your customizations each time you upgrade the software. Instead you need to edit a wiki page called MediaWiki:Common.css if you want to apply your CSS changes for all skins, or a wiki page called MediaWiki:Vector.css if you want to apply the customizations only for the Vector skin.

The content of the MediaWiki:Common.css and MediaWiki:Vector.css pages always overrides the default CSS styles specified in the skin files.

By default, MediaWiki looks for a page with the title Main Page and serves this as the default page. This can be changed by altering the contents of MediaWiki:Mainpage to point to a different title. If this does not change the ‘Main Page’ link included on the sidebar at install time, edit MediaWiki:Sidebar.

To change the default interface language, alter the value of $wgLanguageCode in LocalSettings.php, for example

$wgLanguageCode = "fr";

You may also need to bypass your browser’s cache to see the changes.

The new default interface language will be applied to all users who haven’t ever customised it.

If you want to provide users the possibility to create and choose pages and interface elements in languages other than the default one of the wiki, you need the Translate extension, which can make your wiki multilingual.

If you want to change the language settings for all existing users, use the userOptions.php maintenance script. For instance, to have all users with English set use French instead, run:

php userOptions.php language --old en --new fr

MediaWiki supports uploading and integration of media files. Uploads can be enabled via a configuration setting, although it is recommended that you check certain prerequisites first.

Make sure uploads are enabled in PHP

The following needs to be set in php.ini:

file_uploads = On

If this is not set, PHP scripts cannot use the upload functions, and MediaWiki’s uploads will not be enabled.

If the open_basedir directive is set, it must include both the destination upload folder in your MediaWiki installation (“{$IP}/images”) and the ‘upload_tmp_dir’ folder (default system folder if not set). The addition of the ‘upload_tmp_dir’ can avoid messages like “Could not find file “/var/tmp/php31aWnF” (where in this example the ‘upload_tmp_dir’ is ‘/var/tmp’). Read more about PHP file uploads at File upload basics and in particular move_uploaded_file().

Note: The formal value for the variable is a boolean expression. PHP treats each string not recognized as a False value as true, hence the often used “on” value yields the same result.

Check directory security

The upload directory needs to be configured so that it is not possible for an end user to upload and execute other scripts, which could then exploit access to your web directory and damage your wiki or web site.

Set the /images folder (or the /uploads folder in previous versions) to have permission “755”:

  • User can read, write and execute;
  • Group can read and execute;
  • World can read and execute.

If using safe_mode, make sure the directory is owned by the user used for running the php script (that is, the apache user or, in case of suphp, the script owner).

sudo chown -R www-data:www-data images/

If using CentOS 6 or Mageia the owner:group in the chown command should be “apache:apache” instead of “www-data:www-data”.

If using SELinux, make sure to adjust the ACLs accordingly (see there).

If using suphp, make sure the umask is set to 0022 (or less) in /etc/suphp.conf.

  • Restrict directory listing on images folder

If you don’t want a public user to list your images folder, an option is to set this up in your apache configuration:

        <Directory /var/www/wiki/images>
                Options -Indexes
        </Directory>

Setting uploads on/off

In MediaWiki version 1.5 and later, the attribute to be set resides in LocalSettings.php and $wgEnableUploads is set as follows:

$wgEnableUploads = true; # Enable uploads

This enables uploads, as one might expect. To disable them, set the attribute to false:

$wgEnableUploads = false; # Disable uploads

Upload permissions

Per default, all registered users can upload files. To restrict this, you have to change $wgGroupPermissions:

  • To prevent normal users from uploading files:
    $wgGroupPermissions['user']['upload'] = false;
  • To create a special group called “uploadaccess”, and allow members of that group to upload files:
    $wgGroupPermissions['uploadaccess']['upload'] = true;
  • To allow “autoconfirmed” (non-newbie) users to upload files:
    $wgGroupPermissions['autoconfirmed']['upload'] = true;

The right to replace existing files is handled by an extra permission, called reupload:

  • To prevent normal users from overriding existing files:
    $wgGroupPermissions['user']['reupload'] = false;
  • To allow “autoconfirmed” (non-newbie) users to replace existing files:
    $wgGroupPermissions['autoconfirmed']['reupload'] = true;

If a ForeignFileRepo is set, the right to replace those files locally is handled by an special permission, called reupload-shared:

  • To prevent normal users from overriding filerepo files locally:
    $wgGroupPermissions['user']['reupload-shared'] = false;
  • To allow “autoconfirmed” (non-newbie) users to replace filerepo files locally:
    $wgGroupPermissions['autoconfirmed']['reupload-shared'] = true;

See Manual:User rights for details on user rights, and Manual:Preventing access for more information about restricting access.