Merge "New hook for filters on Special:Contributions form"
[lhc/web/wiklou.git] / docs / distributors.txt
1 This document is intended to provide useful advice for parties seeking to
2 redistribute MediaWiki to end users. It's targeted particularly at maintainers
3 for Linux distributions, since it's been observed that distribution packages of
4 MediaWiki often break. We've consistently had to recommend that users seeking
5 support use official tarballs instead of their distribution's packages, and
6 this often solves whatever problem the user is having. It would be nice if
7 this could change.
8
9 == Background: why web applications are different ==
10
11 MediaWiki is intended to be usable on any web host that provides support for
12 PHP and a database. Many users of low-end shared hosting have very limited
13 access to their machine: often only FTP access to some subdirectory of the web
14 root. Support for these users entails several restrictions, such as:
15
16 1) We cannot require installation of any files outside the web root. Few of
17 our users have access to directories like /usr or /etc.
18 2) We cannot require the ability to run any utility on the command line.
19 Many shared hosts have exec() and similar PHP functions disabled.
20 3) We cannot assume that the software has write access anywhere useful. The
21 user account that MediaWiki (including its installer) runs under is often
22 different from the account the user used to upload the files, and we might be
23 restricted by PHP settings such as safe mode or open_basedir.
24 4) We cannot assume that the software even has read access anywhere useful.
25 Many shared hosts run all users' web applications under the same user, so
26 they can't rely on Unix permissions, and must forbid reads to even standard
27 directories like /tmp lest users read each others' files.
28 5) We cannot assume that the user has the ability to install or run any
29 programs not written as web-accessible PHP scripts.
30
31 Since anything that works on cheap shared hosting will work if you have shell
32 or root access too, MediaWiki's design is based around catering to the lowest
33 common denominator. Although we support higher-end setups as well (like
34 Wikipedia!), the way many things work by default is tailored toward shared
35 hosting. These defaults are unconventional from the point of view of normal
36 (non-web) applications -- they might conflict with distributors' policies, and
37 they certainly aren't ideal for someone who's installing MediaWiki as root.
38
39 == Directory structure ==
40
41 Because of constraint (1) above, MediaWiki does not conform to normal
42 Unix filesystem layout. Hopefully we'll offer direct support for standard
43 layouts in the future, but for now *any change to the location of files is
44 unsupported*. Moving things and leaving symlinks will *probably* not break
45 anything, but it is *strongly* advised not to try any more intrusive changes to
46 get MediaWiki to conform more closely to your filesystem hierarchy. Any such
47 attempt will almost certainly result in unnecessary bugs.
48
49 The standard recommended location to install MediaWiki, relative to the web
50 root, is /w (so, e.g., /var/www/w). Rewrite rules can then be used to enable
51 "pretty URLs" like /wiki/Article instead of /w/index.php?title=Article. (This
52 is the convention Wikipedia uses.) In theory, it should be possible to enable
53 the appropriate rewrite rules by default, if you can reconfigure the web
54 server, but you'd need to alter LocalSettings.php too. See
55 <https://www.mediawiki.org/wiki/Manual:Short_URL> for details on short URLs.
56
57 If you really must mess around with the directory structure, note that the
58 following files *must* all be web-accessible for MediaWiki to function
59 correctly:
60
61 * api.php, img_auth.php, index.php, load.php, opensearch_desc.php, thumb.php,
62 profileinfo.php, redirect.php, trackback.php. These are the entry points for
63 normal usage. This list may be incomplete and is subject to change.
64 * mw-config/index.php: Used for web-based installation (sets up the database,
65 prompts for the name of the wiki, etc.).
66 * images/: Used for uploaded files. This could be somewhere else if
67 $wgUploadDirectory and $wgUploadPath are changed appropriately.
68 * skins/*/: Subdirectories of skins/ contain CSS and JavaScript files that
69 must be accessible to web browsers. The PHP files and Skin.sample in skins/
70 don't need to be accessible. This could be somewhere else if
71 $wgStyleDirectory and $wgStylePath are changed appropriately.
72 * extensions/: Many extensions include CSS and JavaScript files in their
73 extensions directory, and will break if they aren't web-accessible. Some
74 extensions might theoretically provide additional entry points as well, at
75 least in principle.
76
77 But all files should keep their position relative to the web-visible
78 installation directory no matter what. If you must move includes/ somewhere in
79 /usr/share, provide a symlink from /var/www/w. If you don't, you *will* break
80 something. You have been warned.
81
82 == Configuration ==
83
84 MediaWiki is configured using LocalSettings.php. This is a PHP file that's
85 generated when the user visits mw-config/index.php to install the software, and
86 which the user can edit by hand thereafter. It's just a plain old PHP file,
87 and can contain any PHP statements. It usually sets global variables that are
88 used for configuration, and includes files used by any extensions.
89
90 Distributors can easily add extra statements to the autogenerated
91 LocalSettings.php by changing mw-config/overrides.php (see that file for details
92 and examples).
93
94 There's a new maintenance/install.php script which could be used for performing
95 an install through the command line.
96
97 Some configuration options that distributors might be in a position to set
98 intelligently:
99
100 * $wgEmergencyContact: An e-mail address that can be used to contact the wiki
101 administrator. By default, "wikiadmin@ServerName".
102 * $wgPasswordSender: The e-mail address to use when sending password e-mails.
103 By default, "MediaWiki Mail <apache@ServerName>".
104 (with ServerName guessed from the http request)
105 * $wgSMTP: Can be configured to use SMTP for mail sending instead of PHP
106 mail().
107
108 == Updates ==
109
110 The correct way for updating a wiki is to update the files and then run from
111 command line the maintenance/update.php script (with appropriate parameters if
112 files were moved). It will perform all the needed steps to update the database
113 schema and contents to the version from whatever old one it has.
114 Any package manager which replaces the files but doesn't update the db is leaving
115 an inconsistent wiki that may produce blank pages (php errors) when new features
116 using the changed schema would be used.
117
118 Since MediaWiki 1.17 it is possible to upgrade using the installer by providing
119 an arbitrary secret value stored as $wgUpgradeKey in LocalSettings (older versions
120 needed to rename LocalSettings.php in order to upgrade using the installer).
121
122 == Documentation ==
123
124 MediaWiki's official documentation is split between two places: the source
125 code, and <https://www.mediawiki.org/>. The source code documentation is written
126 exclusively by developers, and so is likely to be reliable (at worst,
127 outdated). However, it can be pretty sparse. mediawiki.org documentation is
128 often much more thorough, but it's maintained by a wiki that's open to
129 anonymous edits, so its quality is sometimes sketchy -- don't assume that
130 anything there is officially endorsed!
131
132 == Upstream ==
133
134 MediaWiki is a project hosted and led by the Wikimedia Foundation, the
135 not-for-profit charity that operates Wikipedia. Wikimedia employs the lead
136 developer and several other paid developers, but commit access is given out
137 liberally and there are multiple very active volunteer developers as well. A
138 list of developers can be found at <https://www.mediawiki.org/wiki/Developers>.
139
140 MediaWiki's bug tracker is at <https://bugzilla.wikimedia.org>. However, most
141 developers follow the bug tracker little or not at all. The best place to
142 post if you want to get developers' attention is the wikitech-l mailing list
143 <https://lists.wikimedia.org/mailman/listinfo/wikitech-l>. Posts to wikitech-l
144 will inevitably be read by multiple experienced MediaWiki developers. There's
145 also an active IRC chat at <irc://irc.freenode.net/mediawiki>, where there are
146 usually several developers at reasonably busy times of day.
147
148 Unfortunately, we don't have a very good system for patch review. Patches
149 should be submitted on Bugzilla (as unified diffs produced with "svn diff"
150 against the latest trunk revision), but many patches languish without review
151 until they bitrot into uselessness. You might want to get a developer to
152 commit to reviewing your patch before you put too much effort into it.
153 Reasonably straightforward patches shouldn't be too hard to get accepted if
154 there's an interested developer, however -- posting to Bugzilla and then
155 dropping a note on wikitech-l if nobody responds is a good tactic.
156
157 All redistributors of MediaWiki should be subscribed to mediawiki-announce
158 <https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce>. It's
159 extremely low-traffic, with an average of less than one post per month. All
160 new releases are announced here, including critical security updates.
161
162 == Useful software to install ==
163
164 There are several other pieces of software that MediaWiki can make good use of.
165 Distributors might choose to install these automatically with MediaWiki and
166 perhaps configure it to use them (see Configuration section of this document):
167
168 * APC (Alternative PHP Cache), XCache, or similar: Will greatly speed up the
169 execution of MediaWiki, and all other PHP applications, at some cost in
170 memory usage. Will be used automatically for the most part.
171 * clamav: Can be used for virus scanning of uploaded files. Enable with
172 "$wgAntivirus = 'clamav';".
173 * DjVuLibre: Allows processing of DjVu files. To enable this, set
174 "$wgDjvuDump = 'djvudump'; $wgDjvuRenderer = 'ddjvu'; $wgDjvuTxt = 'djvutxt';".
175 * HTML Tidy: Fixes errors in HTML at runtime. Can be enabled with
176 "$wgUseTidy = true;".
177 * ImageMagick: For resizing images. "$wgUseImageMagick = true;" will enable
178 it. PHP's GD can also be used, but ImageMagick is preferable.
179 * Squid: Can provide a drastic speedup and a major cut in resource
180 consumption, but enabling it may interfere with other applications. It might
181 be suitable for a separate mediawiki-squid package. For setup details, see:
182 <https://www.mediawiki.org/wiki/Manual:Squid_caching>
183 * rsvg or other SVG rasterizer: ImageMagick can be used for SVG support, but
184 is not ideal. Wikipedia (as of the time of this writing) uses rsvg. To
185 enable, set "$wgSVGConverter = 'rsvg';" (or other as appropriate).
186 * texvc: Included with MediaWiki. Instructions for compiling and
187 installing it are in the math/ directory.
188
189 MediaWiki uses some standard GNU utilities as well, such as diff and diff3. If
190 these are present in /usr/bin or some other reasonable location, they will be
191 configured automatically on install.
192
193 MediaWiki also has a "job queue" that handles background processing. Because
194 shared hosts often don't provide access to cron, the job queue is run on every
195 page view by default. This means the background tasks aren't really done in
196 the background. Busy wikis can set $wgJobRunRate to 0 and run
197 maintenance/runJobs.php periodically out of cron. Distributors probably
198 shouldn't set this up as a default, however, since the extra cron job is
199 unnecessary overhead for a little-used wiki.
200
201 == Web server configuration ==
202
203 MediaWiki includes several .htaccess files to restrict access to some
204 directories. If the web server is not configured to support these files, and
205 the relevant directories haven't been moved someplace inaccessible anyway (e.g.
206 symlinked in /usr/share with the web server configured to not follow symlinks),
207 then it might be useful to deny web access to those directories in the web
208 server's configuration.