3 # MediaWiki web-based config/installation
4 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
5 # http://www.mediawiki.org/
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # http://www.gnu.org/copyleft/gpl.html
22 error_reporting( E_ALL
);
23 header( "Content-type: text/html; charset=utf-8" );
24 @ini_set
( "display_errors", true );
26 # In case of errors, let output be clean.
27 $wgRequestTime = microtime( true );
29 # Attempt to set up the include path, to fix problems with relative includes
30 $IP = dirname( dirname( __FILE__
) );
31 define( 'MW_INSTALL_PATH', $IP );
33 # Define an entry point and include some files
34 define( "MEDIAWIKI", true );
35 define( "MEDIAWIKI_INSTALL", true );
37 // Run version checks before including other files
38 // so people don't see a scary parse error.
39 require_once( "$IP/install-utils.inc" );
40 install_version_checks();
42 require_once( "$IP/includes/Defines.php" );
43 require_once( "$IP/includes/DefaultSettings.php" );
44 require_once( "$IP/includes/AutoLoader.php" );
45 require_once( "$IP/includes/MagicWord.php" );
46 require_once( "$IP/includes/Namespace.php" );
47 require_once( "$IP/includes/ProfilerStub.php" );
48 require_once( "$IP/includes/GlobalFunctions.php" );
49 require_once( "$IP/includes/Hooks.php" );
51 # If we get an exception, the user needs to know
53 $wgShowExceptionDetails = true;
55 ## Databases we support:
58 $ourdb['mysql']['fullname'] = 'MySQL';
59 $ourdb['mysql']['havedriver'] = 0;
60 $ourdb['mysql']['compile'] = 'mysql';
61 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
62 $ourdb['mysql']['rootuser'] = 'root';
64 $ourdb['postgres']['fullname'] = 'PostgreSQL';
65 $ourdb['postgres']['havedriver'] = 0;
66 $ourdb['postgres']['compile'] = 'pgsql';
67 $ourdb['postgres']['bgcolor'] = '#aaccff';
68 $ourdb['postgres']['rootuser'] = 'postgres';
71 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
74 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
75 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
76 <style type
="text/css">
78 @import
"../skins/monobook/main.css";
82 margin
: 1em
0 1em
2.5em
;
89 .config
-section label
.column
{
101 zoom
: 100%
; /* IE hack */
104 .config
-section
.config
-desc
{
106 margin
: 0 0 2em
18em
;
111 .iput
-text
, .iput
-password
{
118 background
-color
: #fff;
126 background
-color
: #FFF0F0;
127 border
: 2px solid red
;
135 list-style
-type
: none
;
136 list-style
-image
: none
;
153 span
.success
-message
{
163 <script type
="text/javascript">
166 <?php
foreach (array_keys($ourdb) as $db) {
167 echo "\n document.getElementById('$db').style.display='none';";
172 function toggleDBarea(id
,defaultroot
) {
174 var dbarea
= document
.getElementById(id
).style
;
175 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
176 var db
= document
.getElementById('RootUser');
178 <?php
foreach (array_keys($ourdb) as $db) {
179 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
188 <div id
="globalWrapper">
189 <div id
="column-content">
191 <div id
="bodyContent">
193 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
197 /* Check for existing configurations and bug out! */
199 if( file_exists( "../LocalSettings.php" ) ) {
200 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
201 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
203 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
206 if( file_exists( "./LocalSettings.php" ) ) {
207 writeSuccessMessage();
212 if( !is_writable( "." ) ) {
213 dieout( "<h2>Can't write config file, aborting</h2>
215 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
216 writable by the web server. Once configuration is done you'll move the created
217 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
218 then remove the <tt>config</tt> subdirectory entirely.</p>
220 <p>To make the directory writable on a Unix/Linux system:</p>
223 cd <i>/path/to/wiki</i>
227 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
231 require_once( "$IP/install-utils.inc" );
232 require_once( "$IP/maintenance/updaters.inc" );
235 function getEncoded( $data ) {
236 # removing latin1 support, no need...
239 function getSitename() { return $this->getEncoded( $this->Sitename
); }
240 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
241 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
243 function setSchema( $schema, $engine ) {
244 $this->DBschema
= $schema;
245 if ( !preg_match( '/^\w*$/', $engine ) ){
248 switch ( $this->DBschema
) {
250 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
251 $this->DBmysql5
= 'true';
253 case 'mysql5-binary':
254 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
255 $this->DBmysql5
= 'true';
258 $this->DBTableOptions
= "TYPE=$engine";
259 $this->DBmysql5
= 'false';
261 $this->DBengine
= $engine;
263 # Set the global for use during install
264 global $wgDBTableOptions;
265 $wgDBTableOptions = $this->DBTableOptions
;
273 <b
>Don
't forget security updates!</b> Keep an eye on the
274 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
275 release announcements mailing list</a>.
280 <h2>Checking environment...</h2>
281 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
282 <ul class="env-check">
286 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
287 $conf = new ConfigData;
289 install_version_checks();
290 $self = 'Installer
'; # Maintenance script name, to please Setup.php
292 print "<li>PHP " . phpversion() . " installed</li>\n";
294 error_reporting( 0 );
295 $phpdatabases = array();
296 foreach (array_keys($ourdb) as $db) {
297 $compname = $ourdb[$db]['compile
'];
298 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
299 array_push($phpdatabases, $db);
300 $ourdb[$db]['havedriver
'] = 1;
303 error_reporting( E_ALL );
305 if (!$phpdatabases) {
306 print "Could not find a suitable database driver!<ul>";
307 foreach (array_keys($ourdb) AS $db) {
308 $comp = $ourdb[$db]['compile
'];
309 $full = $ourdb[$db]['fullname
'];
310 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
311 ."or install the $comp.so module</li>\n";
313 dieout( "</ul></ul>" );
316 print "<li>Found database drivers for:";
318 foreach (array_keys($ourdb) AS $db) {
319 if ($ourdb[$db]['havedriver
']) {
320 if ( $DefaultDBtype == '' ) {
321 $DefaultDBtype = $db;
323 print " ".$ourdb[$db]['fullname
'];
328 if( ini_get( "register_globals" ) ) {
331 <div style="font-size:110%">
332 <strong class="error">Warning:</strong>
333 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
335 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
342 if( ini_get( "magic_quotes_runtime" ) ) {
344 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime
</a
> is active
!</strong
>
345 This option corrupts data input unpredictably
; you cannot install
or use
346 MediaWiki unless this option is disabled
.
350 if( ini_get( "magic_quotes_sybase" ) ) {
352 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase
</a
> is active
!</strong
>
353 This option corrupts data input unpredictably
; you cannot install
or use
354 MediaWiki unless this option is disabled
.
358 if( ini_get( "mbstring.func_overload" ) ) {
360 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring
.func_overload
</a
> is active
!</strong
>
361 This option causes errors
and may corrupt data unpredictably
;
362 you cannot install
or use MediaWiki unless this option is disabled
.
366 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
368 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
369 This option causes horrible bugs with MediaWiki
; you cannot install
or use
370 MediaWiki unless this option is disabled
.
376 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
379 if( ini_get( "safe_mode" ) ) {
380 $conf->safeMode
= true;
382 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
383 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
384 You may have problems caused by this
, particularly
if using image uploads
.
388 $conf->safeMode
= false;
391 $sapi = php_sapi_name();
392 print "<li>PHP server API is $sapi; ";
393 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
394 if( $wgUsePathInfo ) {
395 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
397 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
401 $conf->xml
= function_exists( "utf8_encode" );
403 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
405 dieout( "PHP's XML module is missing; the wiki requires functions in
406 this module and won't work in this configuration.
407 If you're running Mandrake, install the php-xml package." );
410 # Check for session support
411 if( !function_exists( 'session_name' ) )
412 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
414 # session.save_path doesn't *have* to be set, but if it is, and it's
415 # not valid/writable/etc. then it can cause problems
416 $sessionSavePath = mw_get_session_save_path();
417 $ssp = htmlspecialchars( $sessionSavePath );
418 # Warn the user if it's not set, but let them proceed
419 if( !$sessionSavePath ) {
420 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
421 has not been set in PHP.ini. If the default value causes problems with
422 saving session data, set it to a valid path which is read/write/execute
423 for the user your web server is running under.</li>";
424 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
425 # All good? Let the user know
426 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
428 # Something not right? Warn the user, but let them proceed
429 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
430 appears to be invalid or is not writable. PHP needs to be able to save data to
431 this location for correct session operation.</li>";
434 # Check for PCRE support
435 if( !function_exists( 'preg_match' ) )
436 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
437 Perl-compatible regular expression functions." );
439 $memlimit = ini_get( "memory_limit" );
440 $conf->raiseMemory
= false;
441 if( empty( $memlimit ) ||
$memlimit == -1 ) {
442 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
444 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
445 $n = intval( $memlimit );
446 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
447 $n = intval( $m[1] * (1024*1024) );
449 if( $n < 20*1024*1024 ) {
450 print "Attempting to raise limit to 20M... ";
451 if( false === ini_set( "memory_limit", "20M" ) ) {
452 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
454 $conf->raiseMemory
= true;
461 $conf->turck
= function_exists( 'mmcache_get' );
462 if ( $conf->turck
) {
463 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
466 $conf->xcache
= function_exists( 'xcache_get' );
468 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
470 $conf->apc
= function_exists('apc_fetch');
472 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
475 $conf->eaccel
= function_exists( 'eaccelerator_get' );
476 if ( $conf->eaccel
) {
477 $conf->turck
= 'eaccelerator';
478 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
481 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
482 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
483 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
484 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
485 cannot use these for object caching.</li>' );
488 $conf->diff3
= false;
489 $diff3locations = array_merge(
496 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
497 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
499 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
500 foreach ($diff3locations as $loc) {
501 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
502 if ($exe !== false) {
509 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
511 print "<li>GNU diff3 not found.</li>";
513 $conf->ImageMagick
= false;
514 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
515 foreach( $imcheck as $dir ) {
516 $im = "$dir/convert";
517 if( @file_exists
( $im ) ) {
518 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
519 $conf->ImageMagick
= $im;
524 $conf->HaveGD
= function_exists( "imagejpeg" );
525 if( $conf->HaveGD
) {
526 print "<li>Found GD graphics library built-in";
527 if( !$conf->ImageMagick
) {
528 print ", image thumbnailing will be enabled if you enable uploads";
532 if( !$conf->ImageMagick
) {
533 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
537 $conf->IP
= dirname( dirname( __FILE__
) );
538 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
541 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
542 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
543 // to get the path to the current script... hopefully it's reliable. SIGH
544 $path = ($_SERVER["PHP_SELF"] === '')
545 ?
$_SERVER["SCRIPT_NAME"]
546 : $_SERVER["PHP_SELF"];
548 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
549 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
553 // We may be installing from *.php5 extension file, if so, print message
554 $conf->ScriptExtension
= '.php';
555 if (defined('MW_INSTALL_PHP5_EXT')) {
556 $conf->ScriptExtension
= '.php5';
557 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
559 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
563 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
564 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
566 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
567 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
569 : $_SERVER["SERVER_ADMIN"];
570 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
571 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
575 $conf->DBserver
= importPost( "DBserver", "localhost" );
576 $conf->DBname
= importPost( "DBname", "wikidb" );
577 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
578 $conf->DBpassword
= importPost( "DBpassword" );
579 $conf->DBpassword2
= importPost( "DBpassword2" );
580 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
581 $conf->SysopPass
= importPost( "SysopPass" );
582 $conf->SysopPass2
= importPost( "SysopPass2" );
583 $conf->RootUser
= importPost( "RootUser", "root" );
584 $conf->RootPW
= importPost( "RootPW", "" );
585 $useRoot = importCheck( 'useroot', false );
586 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
589 $conf->DBprefix
= importPost( "DBprefix" );
591 importPost( "DBschema", "mysql4" ),
592 importPost( "DBengine", "InnoDB" ) );
594 ## Postgres specific:
595 $conf->DBport
= importPost( "DBport", "5432" );
596 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
597 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
599 /* Check for validity */
602 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
603 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
605 if( $conf->DBuser
== "" ) {
606 $errs["DBuser"] = "Must not be blank";
608 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
609 $errs["DBuser"] = "Username too long";
611 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
612 $errs["DBpassword"] = "Must not be blank";
614 if( $conf->DBpassword
!= $conf->DBpassword2
) {
615 $errs["DBpassword2"] = "Passwords don't match!";
617 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
618 $errs["DBprefix"] = "Invalid table prefix";
621 error_reporting( E_ALL
);
624 * Initialise $wgLang and $wgContLang to something so we can
625 * call case-folding methods. Per Brion, this is English for
626 * now, although we could be clever and initialise to the
627 * user-selected language.
629 $wgContLang = Language
::factory( 'en' );
630 $wgLang = $wgContLang;
633 * We're messing about with users, so we need a stub
634 * authentication plugin...
636 $wgAuth = new AuthPlugin();
639 * Validate the initial administrator account; username,
640 * password checks, etc.
642 if( $conf->SysopName
) {
643 # Check that the user can be created
644 $u = User
::newFromName( $conf->SysopName
);
645 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
646 # Various password checks
647 if( $conf->SysopPass
!= '' ) {
648 if( $conf->SysopPass
== $conf->SysopPass2
) {
649 if( !$u->isValidPassword( $conf->SysopPass
) ) {
650 $errs['SysopPass'] = "Bad password";
653 $errs['SysopPass2'] = "Passwords don't match";
656 $errs['SysopPass'] = "Cannot be blank";
660 $errs['SysopName'] = "Bad username";
664 $conf->License
= importRequest( "License", "none" );
665 if( $conf->License
== "gfdl" ) {
666 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
667 $conf->RightsText
= "GNU Free Documentation License 1.2";
668 $conf->RightsCode
= "gfdl";
669 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
670 } elseif( $conf->License
== "none" ) {
671 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
673 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
674 $conf->RightsText
= importRequest( "RightsText", "" );
675 $conf->RightsCode
= importRequest( "RightsCode", "" );
676 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
679 $conf->Shm
= importRequest( "Shm", "none" );
680 $conf->MCServers
= importRequest( "MCServers" );
682 /* Test memcached servers */
684 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
685 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
686 foreach ( $conf->MCServerArray
as $server ) {
687 $error = testMemcachedServer( $server );
689 $errs["MCServers"] = $error;
693 } else if ( $conf->Shm
== 'memcached' ) {
694 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
697 /* default values for installation */
698 $conf->Email
= importRequest("Email", "email_enabled");
699 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
700 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
701 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
703 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
704 do { /* So we can 'continue' to end prematurely */
705 $conf->Root
= ($conf->RootPW
!= "");
707 /* Load up the settings and get installin' */
708 $local = writeLocalSettings( $conf );
709 echo "<li style=\"list-style: none\">\n";
710 echo "<p><b>Generating configuration file...</b></p>\n";
713 $wgCommandLineMode = false;
715 $ok = eval( $local );
716 if( $ok === false ) {
717 dieout( "Errors in generated configuration; " .
718 "most likely due to a bug in the installer... " .
719 "Config file was: " .
721 htmlspecialchars( $local ) .
725 $conf->DBtypename
= '';
726 foreach (array_keys($ourdb) as $db) {
727 if ($conf->DBtype
=== $db)
728 $conf->DBtypename
= $ourdb[$db]['fullname'];
730 if ( ! strlen($conf->DBtype
)) {
731 $errs["DBpicktype"] = "Please choose a database type";
735 if (! $conf->DBtypename
) {
736 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
739 print "<li>Database type: {$conf->DBtypename}</li>\n";
740 $dbclass = 'Database'.ucfirst($conf->DBtype
);
741 $wgDBtype = $conf->DBtype
;
742 $wgDBadminuser = "root";
743 $wgDBadminpassword = $conf->RootPW
;
746 $wgDBprefix = $conf->DBprefix
;
748 ## Postgres specific:
749 $wgDBport = $conf->DBport
;
750 $wgDBmwschema = $conf->DBmwschema
;
751 $wgDBts2schema = $conf->DBts2schema
;
753 $wgCommandLineMode = true;
754 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
755 require_once( "$IP/includes/Setup.php" );
758 $wgTitle = Title
::newFromText( "Installation script" );
759 error_reporting( E_ALL
);
760 print "<li>Loading class: $dbclass";
763 if( $conf->DBtype
== 'mysql' ) {
764 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
765 if( $mysqlOldClient ) {
766 print "<li><b>PHP is linked with old MySQL client libraries. If you are
767 using a MySQL 4.1 server and have problems connecting to the database,
768 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
769 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
771 $ok = true; # Let's be optimistic
773 # Decide if we're going to use the superuser or the regular database user
774 $conf->Root
= $useRoot;
776 $db_user = $conf->RootUser
;
777 $db_pass = $conf->RootPW
;
779 $db_user = $wgDBuser;
780 $db_pass = $wgDBpassword;
784 echo( "<li>Attempting to connect to database server as $db_user..." );
785 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
787 # Check the connection and respond to errors
788 if( $wgDatabase->isOpen() ) {
791 $wgDBadminuser = $db_user;
792 $wgDBadminpassword = $db_pass;
793 echo( "success.</li>\n" );
794 $wgDatabase->ignoreErrors( true );
795 $myver = $wgDatabase->getServerVersion();
797 # There were errors, report them and back out
799 $errno = mysql_errno();
800 $errtx = htmlspecialchars( mysql_error() );
804 echo( "failed due to authentication errors. Check passwords.</li>" );
806 # The superuser details are wrong
807 $errs["RootUser"] = "Check username";
808 $errs["RootPW"] = "and password";
810 # The regular user details are wrong
811 $errs["DBuser"] = "Check username";
812 $errs["DBpassword"] = "and password";
818 # General connection problem
819 echo( "failed with error [$errno] $errtx.</li>\n" );
820 $errs["DBserver"] = "Connection failed";
825 if( !$ok ) { continue; }
827 } else /* not mysql */ {
828 error_reporting( E_ALL
);
830 ## Possible connect as a superuser
832 $wgDBsuperuser = $conf->RootUser
;
833 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
834 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
835 if (!$wgDatabase->isOpen()) {
836 print " error: " . $wgDatabase->lastError() . "</li>\n";
837 $errs["DBserver"] = "Could not connect to database as superuser";
838 $errs["RootUser"] = "Check username";
839 $errs["RootPW"] = "and password";
843 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
844 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
845 if (!$wgDatabase->isOpen()) {
846 print " error: " . $wgDatabase->lastError() . "</li>\n";
848 $myver = $wgDatabase->getServerVersion();
852 if ( !$wgDatabase->isOpen() ) {
853 $errs["DBserver"] = "Couldn't connect to database";
857 print "<li>Connected to $myver";
858 if ($conf->DBtype
== 'mysql') {
859 if( version_compare( $myver, "4.0.14" ) < 0 ) {
860 dieout( " -- mysql 4.0.14 or later required. Aborting." );
862 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
863 if( $mysqlNewAuth && $mysqlOldClient ) {
864 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
865 to old client libraries; if you have trouble with authentication, see
866 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
867 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
870 if( $mysqlNewAuth ) {
871 print "; enabling MySQL 4.1/5.0 charset mode";
873 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
874 but older version detected; will likely fail.</b>";
879 @$sel = $wgDatabase->selectDB( $wgDBname );
881 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
883 $err = mysql_errno();
884 $databaseSafe = htmlspecialchars( $wgDBname );
885 if( $err == 1102 /* Invalid database name */ ) {
886 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
888 } elseif( $err != 1049 /* Database doesn't exist */ ) {
889 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
890 print htmlspecialchars( mysql_error() ) . "</li></ul>";
893 print "<li>Attempting to create database...</li>";
894 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
896 print "<li>Couldn't create database <tt>" .
897 htmlspecialchars( $wgDBname ) .
898 "</tt>; try with root access or check your username/pass.</li>\n";
899 $errs["RootPW"] = "<- Enter";
902 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
904 $wgDatabase->selectDB( $wgDBname );
906 else if ($conf->DBtype
== 'postgres') {
907 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
908 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
912 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
913 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
915 if ( $conf->DBtype
== 'mysql') {
916 # Determine existing default character set
917 if ( $wgDatabase->tableExists( "revision" ) ) {
918 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
919 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
920 $row = $wgDatabase->fetchObject( $res );
922 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
923 $existingSchema = false;
924 $existingEngine = false;
926 if ( preg_match( '/^latin1/', $row->Collation
) ) {
927 $existingSchema = 'mysql4';
928 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
929 $existingSchema = 'mysql5';
930 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
931 $existingSchema = 'mysql5-binary';
933 $existingSchema = false;
934 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
936 if ( isset( $row->Engine
) ) {
937 $existingEngine = $row->Engine
;
939 $existingEngine = $row->Type
;
942 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
943 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
944 "but the existing database has the $existingSchema schema. This upgrade script ".
945 "can't convert it, so it will remain $existingSchema.</li>\n";
946 $conf->setSchema( $existingSchema, $conf->DBengine
);
948 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
949 print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
950 "engine, but the existing database uses the $existingEngine engine. This upgrade " .
951 "script can't convert it, so it will remain $existingEngine.</li>\n";
952 $conf->setSchema( $conf->DBschema
, $existingEngine );
956 # Create user if required
958 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
959 if ( $conn->isOpen() ) {
960 print "<li>DB user account ok</li>\n";
963 print "<li>Granting user permissions...";
964 if( $mysqlOldClient && $mysqlNewAuth ) {
965 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
968 dbsource( "../maintenance/users.sql", $wgDatabase );
972 print "</ul><pre>\n";
978 print "<ul><li>Finished update checks.</li>\n";
980 # Determine available storage engines if possible
981 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
982 $res = $wgDatabase->query( 'SHOW ENGINES' );
984 while ( $row = $wgDatabase->fetchObject( $res ) ) {
985 if ( $row->Engine
== $conf->DBengine
) {
990 $wgDatabase->freeResult( $res );
991 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
992 echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
993 "using MyISAM instead</li>\n";
994 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
998 # FIXME: Check for errors
999 print "<li>Creating tables...";
1000 if ($conf->DBtype
== 'mysql') {
1001 dbsource( "../maintenance/tables.sql", $wgDatabase );
1002 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1003 } else if ($conf->DBtype
== 'postgres') {
1004 $wgDatabase->setup_database();
1007 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1011 print " done.</li>\n";
1013 print "<li>Initializing statistics...</li>\n";
1014 $wgDatabase->insert( 'site_stats',
1015 array ( 'ss_row_id' => 1,
1016 'ss_total_views' => 0,
1017 'ss_total_edits' => 1, # Main page first edit
1018 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1019 'ss_total_pages' => 1, # Main page
1020 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1021 'ss_images' => 0 ) );
1023 # Set up the "regular user" account *if we can, and if we need to*
1024 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1026 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1027 if( $wgDatabase2->isOpen() ) {
1028 # Nope, just close the test connection and continue
1029 $wgDatabase2->close();
1030 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
1032 # Yes, so run the grants
1033 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
1034 dbsource( "../maintenance/users.sql", $wgDatabase );
1035 echo( "success.</li>\n" );
1039 if( $conf->SysopName
) {
1040 $u = User
::newFromName( $conf->getSysopName() );
1042 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1044 else if ( 0 == $u->idForName() ) {
1045 $u->addToDatabase();
1046 $u->setPassword( $conf->getSysopPass() );
1049 $u->addGroup( "sysop" );
1050 $u->addGroup( "bureaucrat" );
1052 print "<li>Created sysop account <tt>" .
1053 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1055 print "<li>Could not create user - already exists!</li>\n";
1058 print "<li>Skipped sysop account creation, no name given.</li>\n";
1061 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1062 $article = new Article( $titleobj );
1063 $newid = $article->insertOn( $wgDatabase );
1064 $revision = new Revision( array(
1066 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1069 'user_text' => 'MediaWiki default',
1071 $revid = $revision->insertOn( $wgDatabase );
1072 $article->updateRevisionOn( $wgDatabase, $revision );
1075 /* Write out the config file now that all is well */
1076 print "<li style=\"list-style: none\">\n";
1077 print "<p>Creating LocalSettings.php...</p>\n\n";
1078 $localSettings = "<" . "?php$endl$local";
1079 // Fix up a common line-ending problem (due to CVS on Windows)
1080 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1081 $f = fopen( "LocalSettings.php", 'xt' );
1084 dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
1085 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1086 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1088 if(fwrite( $f, $localSettings ) ) {
1090 print "</li></ul><hr/>\n";
1091 writeSuccessMessage();
1094 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
1095 print "</li></ul>\n";
1106 if( count( $errs ) ) {
1107 /* Display options form */
1109 if( $conf->posted
) {
1110 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1114 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1117 <h2
>Site config
</h2
>
1119 <div
class="config-section">
1120 <div
class="config-input">
1122 aField( $conf, "Sitename", "Wiki name:" );
1125 <p
class="config-desc">
1126 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1127 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1130 <div
class="config-input">
1132 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1135 <p
class="config-desc">
1136 Displayed to users in some error messages
, used
as the
return address
for password reminders
, and used
as the
default sender address of e
-mail notifications
.
1139 <div
class="config-input">
1140 <label
class='column' for="LanguageCode">Language
:</label
>
1141 <select id
="LanguageCode" name
="LanguageCode">
1144 $list = getLanguageList();
1145 foreach( $list as $code => $name ) {
1146 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1147 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1152 <p
class="config-desc">
1153 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1156 <div
class="config-input">
1157 <label
class='column'>Copyright
/license
:</label
>
1160 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1161 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1163 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1164 $partner = "MediaWiki";
1165 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1166 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1167 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1168 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1169 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1171 <?php
if( $conf->License
== "cc" ) { ?
>
1173 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1174 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1175 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1176 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1182 <p
class="config-desc">
1183 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1187 <div
class="config-input">
1188 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1190 <div
class="config-input">
1191 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1193 <div
class="config-input">
1194 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1196 <p
class="config-desc">
1197 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1198 A
new account will be added only when creating a
new wiki database
.
1200 The password cannot be the same
as the username
.
1203 <div
class="config-input">
1204 <label
class='column'>Shared memory caching
:</label
>
1207 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1209 if ( $conf->turck
) {
1211 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1214 if( $conf->xcache
) {
1216 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1221 aField( $conf, "Shm", "APC", "radio", "apc" );
1224 if ( $conf->eaccel
) {
1226 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1230 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1232 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1234 <p
class="config-desc">
1235 An
object caching system such
as memcached will provide a significant performance boost
,
1236 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1238 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1239 these should not be used
if the wiki will be running on multiple application servers
.
1243 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1245 <div
class="config-section">
1246 <div
class="config-input">
1247 <label
class='column'>E
-mail
features (global):</label
>
1249 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1250 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1253 <p
class="config-desc">
1254 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1255 if sending mail doesn
't work on your server.
1258 <div class="config-input">
1259 <label class='column
'>User-to-user e-mail:</label>
1261 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1262 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1265 <p class="config-desc">
1266 The user-to-user e-mail feature (Special:Emailuser) lets the wiki act as a relay to allow users to exchange e-mail without publicly advertising their e-mail address.
1268 <div class="config-input">
1269 <label class='column
'>E-mail notification about changes:</label>
1271 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1272 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1273 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1276 <div class="config-desc">
1278 For this feature to work, an e-mail address must be present for the user account, and the notification
1279 options in the user's preferences must be enabled
. Also note the
1280 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1282 <p
>There are additional options
for fine tuning in
/includes
/DefaultSettings
.php
; copy these to your LocalSettings
.php
and edit them there to change them
.</p
>
1285 <div
class="config-input">
1286 <label
class='column'>E
-mail address authentication
:</label
>
1288 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1289 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1292 <div
class="config-desc">
1293 <p
>If this option is enabled
, users have to confirm their e
-mail address using a magic link sent to them whenever they set
or change it
, and only authenticated e
-mail addresses can receive mails from other users
and/or
1294 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1299 <h2
>Database config
</h2
>
1301 <div
class="config-section">
1302 <div
class="config-input">
1303 <label
class='column'>Database type
:</label
>
1304 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1305 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1308 <div
class="config-input" style
="clear:left"><?php
1309 aField( $conf, "DBserver", "Database host:" );
1311 <p
class="config-desc">
1312 If your database server isn
't on your web server, enter the name or IP address here.
1315 <div class="config-input"><?php
1316 aField( $conf, "DBname", "Database name:" );
1318 <div class="config-input"><?php
1319 aField( $conf, "DBuser", "DB username:" );
1321 <div class="config-input"><?php
1322 aField( $conf, "DBpassword", "DB password:", "password" );
1324 <div class="config-input"><?php
1325 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1327 <p class="config-desc">
1328 If you only have a single user account and database available,
1329 enter those here. If you have database root access (see below)
1330 you can specify new accounts/databases to be created. This account
1331 will not be created if it pre-exists. If this is the case, ensure that it
1332 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1335 <div class="config-input">
1336 <label class="column">Superuser account:</label>
1337 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1338 <label for="useroot">Use superuser account</label>
1340 <div class="config-input">
1342 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1345 <div class="config-input">
1347 aField( $conf, "RootPW", "Superuser password:", "password" );
1351 <p class="config-desc">
1352 If the database user specified above does not exist, or does not have access to create
1353 the database (if needed) or tables within it, please check the box and provide details
1354 of a superuser account, such as <strong>root</strong>, which does.
1357 <?php database_switcher('mysql
'); ?>
1358 <div class="config-input"><?php
1359 aField( $conf, "DBprefix", "Database table prefix:" );
1361 <div class="config-desc">
1362 <p>If you need to share one database between multiple wikis, or
1363 between MediaWiki and another web application, you may choose to
1364 add a prefix to all the table names to avoid conflicts.</p>
1366 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1369 <div class="config-input"><label class="column">Storage Engine</label>
1370 <div>Select one:</div>
1372 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1373 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1376 <p class="config-desc">
1377 InnoDB is best for public web installations, since it has good concurrency
1378 support. MyISAM may be faster in single-user installations. MyISAM databases
1379 tend to get corrupted more often than InnoDB databases.
1381 <div class="config-input"><label class="column">Database character set</label>
1382 <div>Select one:</div>
1384 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1385 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1386 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1389 <p class="config-desc">
1390 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1391 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1392 cause things to break. <b>If upgrading an older installation, leave
1393 in backwards-compatible mode.</b>
1397 <?php database_switcher('postgres
'); ?>
1398 <div class="config-input"><?php
1399 aField( $conf, "DBport", "Database port:" );
1401 <div class="config-input"><?php
1402 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1404 <div class="config-input"><?php
1405 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1407 <div class="config-desc">
1408 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1409 so it is recommended that you create a new user. The above schemas are generally correct:
1410 only change them if you are sure you need to.</p>
1414 <div class="config-input" style="padding:2em 0 3em">
1415 <label class='column
'> </label>
1416 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1421 <script type="text/javascript">
1422 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1424 ## If they passed in a root user name, don't populate it on page load
1425 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1434 /* -------------------------------------------------------------------------------------- */
1435 function writeSuccessMessage() {
1436 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1437 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1439 <div class="success-box">
1440 <p>Installation successful!</p>
1441 <p>To complete the installation, please do the following:
1443 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1444 <li>Upload it to the parent directory</li>
1445 <li>Delete config/LocalSettings.php</li>
1446 <li>Start using <a href='../$script'>your wiki</a>!
1448 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1449 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1450 which means that anyone on the same server can read your database password! Downloading
1451 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1456 <div class="success-box">
1458 <span class="success-message">Installation successful!</span>
1459 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1460 <a href="../$script"> this link</a> to your wiki.</p>
1461 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1462 prevent other users on the server reading passwords and altering configuration data.</p>
1469 function escapePhpString( $string ) {
1470 return strtr( $string,
1481 function writeLocalSettings( $conf ) {
1482 $conf->PasswordSender
= $conf->EmergencyContact
;
1483 $magic = ($conf->ImageMagick ?
"" : "# ");
1484 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1485 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1486 $hashedUploads = $conf->safeMode ?
'' : '# ';
1488 switch ( $conf->Shm
) {
1490 $cacheType = 'CACHE_MEMCACHED';
1491 $mcservers = var_export( $conf->MCServerArray
, true );
1497 $cacheType = 'CACHE_ACCEL';
1498 $mcservers = 'array()';
1501 $cacheType = 'CACHE_NONE';
1502 $mcservers = 'array()';
1505 if ( $conf->Email
== 'email_enabled' ) {
1506 $enableemail = 'true';
1507 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1508 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1509 switch ( $conf->Enotif
) {
1510 case 'enotif_usertalk':
1511 $enotifusertalk = 'true';
1512 $enotifwatchlist = 'false';
1514 case 'enotif_allpages':
1515 $enotifusertalk = 'true';
1516 $enotifwatchlist = 'true';
1519 $enotifusertalk = 'false';
1520 $enotifwatchlist = 'false';
1523 $enableuseremail = 'false';
1524 $enableemail = 'false';
1525 $eauthent = 'false';
1526 $enotifusertalk = 'false';
1527 $enotifwatchlist = 'false';
1530 $file = @fopen
( "/dev/urandom", "r" );
1532 $secretKey = bin2hex( fread( $file, 32 ) );
1536 for ( $i=0; $i<8; $i++
) {
1537 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1539 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1542 # Add slashes to strings for double quoting
1543 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1544 if( $conf->License
== 'gfdl' ) {
1545 # Needs literal string interpolation for the current style path
1546 $slconf['RightsIcon'] = $conf->RightsIcon
;
1550 # This file was automatically generated by the MediaWiki installer.
1551 # If you make manual changes, please keep track in case you need to
1552 # recreate them later.
1554 # See includes/DefaultSettings.php for all configurable settings
1555 # and their default values, but don't forget to make changes in _this_
1558 # If you customize your file layout, set \$IP to the directory that contains
1559 # the other MediaWiki files. It will be used as a base to locate files.
1560 if( defined( 'MW_INSTALL_PATH' ) ) {
1561 \$IP = MW_INSTALL_PATH;
1563 \$IP = dirname( __FILE__ );
1566 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1567 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1569 require_once( \"\$IP/includes/DefaultSettings.php\" );
1571 # If PHP's memory limit is very low, some operations may fail.
1572 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1574 if ( \$wgCommandLineMode ) {
1575 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1576 die( \"This script must be run from the command line\\n\" );
1579 ## Uncomment this to disable output compression
1580 # \$wgDisableOutputCompression = true;
1582 \$wgSitename = \"{$slconf['Sitename']}\";
1584 ## The URL base path to the directory containing the wiki;
1585 ## defaults for all runtime URL paths are based off of this.
1586 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1587 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1589 ## For more information on customizing the URLs please see:
1590 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1592 \$wgEnableEmail = $enableemail;
1593 \$wgEnableUserEmail = $enableuseremail;
1595 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1596 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1598 ## For a detailed description of the following switches see
1599 ## http://www.mediawiki.org/wiki/Extension:Email_notification
1600 ## and http://www.mediawiki.org/wiki/Extension:Email_notification
1601 ## There are many more options for fine tuning available see
1602 ## /includes/DefaultSettings.php
1603 ## UPO means: this is also a user preference option
1604 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1605 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1606 \$wgEmailAuthentication = $eauthent;
1608 \$wgDBtype = \"{$slconf['DBtype']}\";
1609 \$wgDBserver = \"{$slconf['DBserver']}\";
1610 \$wgDBname = \"{$slconf['DBname']}\";
1611 \$wgDBuser = \"{$slconf['DBuser']}\";
1612 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1614 # MySQL specific settings
1615 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1617 # MySQL table options to use during installation or update
1618 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1620 # Experimental charset support for MySQL 4.1/5.0.
1621 \$wgDBmysql5 = {$conf->DBmysql5};
1623 # Postgres specific settings
1624 \$wgDBport = \"{$slconf['DBport']}\";
1625 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1626 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1628 ## Shared memory settings
1629 \$wgMainCacheType = $cacheType;
1630 \$wgMemCachedServers = $mcservers;
1632 ## To enable image uploads, make sure the 'images' directory
1633 ## is writable, then set this to true:
1634 \$wgEnableUploads = false;
1635 {$magic}\$wgUseImageMagick = true;
1636 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1638 ## If you want to use image uploads under safe mode,
1639 ## create the directories images/archive, images/thumb and
1640 ## images/temp, and make them all writable. Then uncomment
1641 ## this, if it's not already uncommented:
1642 {$hashedUploads}\$wgHashedUploadDirectory = false;
1644 ## If you have the appropriate support software installed
1645 ## you can enable inline LaTeX equations:
1648 \$wgLocalInterwiki = \$wgSitename;
1650 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1652 \$wgProxyKey = \"$secretKey\";
1654 ## Default skin: you can change the default skin. Use the internal symbolic
1655 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1656 \$wgDefaultSkin = 'monobook';
1658 ## For attaching licensing metadata to pages, and displaying an
1659 ## appropriate copyright notice / icon. GNU Free Documentation
1660 ## License and Creative Commons licenses are supported so far.
1661 {$rights}\$wgEnableCreativeCommonsRdf = true;
1662 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1663 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1664 \$wgRightsText = \"{$slconf['RightsText']}\";
1665 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1666 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1668 \$wgDiff3 = \"{$slconf['diff3']}\";
1670 # When you make changes to this configuration file, this will make
1671 # sure that cached pages are cleared.
1672 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1673 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1674 "; ## End of setting the $localsettings string
1676 // Keep things in Unix line endings internally;
1677 // the system will write out as local text type.
1678 return str_replace( "\r\n", "\n", $localsettings );
1681 function dieout( $text ) {
1682 die( $text . "\n\n</body>\n</html>" );
1685 function importVar( &$var, $name, $default = "" ) {
1686 if( isset( $var[$name] ) ) {
1687 $retval = $var[$name];
1688 if ( get_magic_quotes_gpc() ) {
1689 $retval = stripslashes( $retval );
1697 function importPost( $name, $default = "" ) {
1698 return importVar( $_POST, $name, $default );
1701 function importCheck( $name ) {
1702 return isset( $_POST[$name] );
1705 function importRequest( $name, $default = "" ) {
1706 return importVar( $_REQUEST, $name, $default );
1711 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1714 $xtype = "type=\"$type\"";
1720 $nolabel = ($type == "radio") ||
($type == "hidden");
1722 if ($type == 'radio')
1723 $id .= $radioCount++
;
1728 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1731 if( $type == "radio" && $value == $conf->$field ) {
1732 $checked = "checked='checked'";
1736 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1738 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1741 if( $type == "radio" ) {
1742 echo htmlspecialchars( $value );
1744 echo htmlspecialchars( $conf->$field );
1750 echo " $text</label>\n";
1754 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1757 function getLanguageList() {
1758 global $wgLanguageNames, $IP;
1759 if( !isset( $wgLanguageNames ) ) {
1760 require_once( "$IP/languages/Names.php" );
1765 $d = opendir( "../languages/messages" );
1766 /* In case we are called from the root directory */
1768 $d = opendir( "languages/messages");
1769 while( false !== ($f = readdir( $d ) ) ) {
1771 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1772 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1773 if( isset( $wgLanguageNames[$code] ) ) {
1774 $name = $code . ' - ' . $wgLanguageNames[$code];
1778 $codes[$code] = $name;
1786 #Check for location of an executable
1787 # @param string $loc single location to check
1788 # @param array $names filenames to check for.
1789 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1790 function locate_executable($loc, $names, $versioninfo = false) {
1791 if (!is_array($names))
1792 $names = array($names);
1794 foreach ($names as $name) {
1795 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1796 if (@file_exists
($command)) {
1800 $file = str_replace('$1', $command, $versioninfo[0]);
1801 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1808 # Test a memcached server
1809 function testMemcachedServer( $server ) {
1810 $hostport = explode(":", $server);
1813 if ( !function_exists( 'fsockopen' ) ) {
1814 $errstr = "Can't connect to memcached, fsockopen() not present";
1816 if ( !$errstr && count( $hostport ) != 2 ) {
1817 $errstr = 'Please specify host and port';
1818 var_dump( $hostport );
1821 list( $host, $port ) = $hostport;
1825 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1826 if ( $fp === false ) {
1827 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1831 $command = "version\r\n";
1832 $bytes = fwrite( $fp, $command );
1833 if ( $bytes != strlen( $command ) ) {
1834 $errstr = "Cannot write to memcached socket on $host:$port";
1838 $expected = "VERSION ";
1839 $response = fread( $fp, strlen( $expected ) );
1840 if ( $response != $expected ) {
1841 $errstr = "Didn't get correct memcached response from $host:$port";
1848 echo "<li>Connected to memcached on $host:$port successfully";
1853 function database_picker($conf) {
1856 foreach(array_keys($ourdb) as $db) {
1857 if ($ourdb[$db]['havedriver']) {
1859 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1866 function database_switcher($db) {
1868 $color = $ourdb[$db]['bgcolor'];
1869 $full = $ourdb[$db]['fullname'];
1870 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
1873 function printListItem( $item ) {
1874 print "<li>$item</li>";
1879 <div
class="license">
1881 <p
>This program is free software
; you can redistribute it
and/or modify
1882 it under the terms of the GNU General
Public License
as published by
1883 the Free Software Foundation
; either version
2 of the License
, or
1884 (at your option
) any later version
.</p
>
1886 <p
>This program is distributed in the hope that it will be useful
,
1887 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1888 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1889 GNU General
Public License
for more details
.</p
>
1891 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1892 along with this program
; if not
, write to the Free Software
1893 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1894 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1900 <div id
="column-one">
1901 <div
class="portlet" id
="p-logo">
1902 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1903 href
="http://www.mediawiki.org/"
1904 title
="Main Page"></a
>
1906 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1907 <div
class='portlet'><div
class='pBody'>
1909 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1910 <li
><a href
="../README">Readme
</a
></li
>
1911 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1912 <li
><a href
="../docs/">Documentation
</a
></li
>
1913 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1914 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1916 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2007 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>