distributors.txt 11 KB

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