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';
70 $ourdb['sqlite']['fullname'] = 'SQLite';
71 $ourdb['sqlite']['havedriver'] = 0;
72 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
73 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
74 $ourdb['sqlite']['rootuser'] = '';
76 $ourdb['mssql']['fullname'] = 'MSSQL';
77 $ourdb['mssql']['havedriver'] = 0;
78 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
79 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
80 $ourdb['mssql']['rootuser'] = 'administrator';
83 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
86 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
87 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
88 <style type
="text/css">
90 @import
"../skins/monobook/main.css";
94 margin
: 1em
0 1em
2.5em
;
101 .config
-section label
.column
{
113 zoom
: 100%
; /* IE hack */
116 .config
-section
.config
-desc
{
118 margin
: 0 0 2em
18em
;
123 .iput
-text
, .iput
-password
{
130 background
-color
: #fff;
138 background
-color
: #FFF0F0;
139 border
: 2px solid red
;
147 list-style
-type
: none
;
148 list-style
-image
: none
;
165 span
.success
-message
{
175 <script type
="text/javascript">
178 <?php
foreach (array_keys($ourdb) as $db) {
179 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
184 function toggleDBarea(id
,defaultroot
) {
186 var dbarea
= document
.getElementById(id
);
187 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
188 var db
= document
.getElementById('RootUser');
190 <?php
foreach (array_keys($ourdb) as $db) {
191 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
200 <div id
="globalWrapper">
201 <div id
="column-content">
203 <div id
="bodyContent">
205 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
209 /* Check for existing configurations and bug out! */
211 if( file_exists( "../LocalSettings.php" ) ) {
212 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
213 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
215 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
218 if( file_exists( "./LocalSettings.php" ) ) {
219 writeSuccessMessage();
224 if( !is_writable( "." ) ) {
225 dieout( "<h2>Can't write config file, aborting</h2>
227 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
228 writable by the web server. Once configuration is done you'll move the created
229 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
230 then remove the <tt>config</tt> subdirectory entirely.</p>
232 <p>To make the directory writable on a Unix/Linux system:</p>
235 cd <i>/path/to/wiki</i>
239 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
243 require_once( "$IP/install-utils.inc" );
244 require_once( "$IP/maintenance/updaters.inc" );
247 function getEncoded( $data ) {
248 # removing latin1 support, no need...
251 function getSitename() { return $this->getEncoded( $this->Sitename
); }
252 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
253 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
255 function setSchema( $schema, $engine ) {
256 $this->DBschema
= $schema;
257 if ( !preg_match( '/^\w*$/', $engine ) ){
260 switch ( $this->DBschema
) {
262 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
263 $this->DBmysql5
= 'true';
265 case 'mysql5-binary':
266 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
267 $this->DBmysql5
= 'true';
270 $this->DBTableOptions
= "TYPE=$engine";
271 $this->DBmysql5
= 'false';
273 $this->DBengine
= $engine;
275 # Set the global for use during install
276 global $wgDBTableOptions;
277 $wgDBTableOptions = $this->DBTableOptions
;
285 <b
>Don
't forget security updates!</b> Keep an eye on the
286 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
287 release announcements mailing list</a>.
292 <h2>Checking environment...</h2>
293 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
294 <ul class="env-check">
298 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
299 $conf = new ConfigData;
301 install_version_checks();
302 $self = 'Installer
'; # Maintenance script name, to please Setup.php
304 print "<li>PHP " . phpversion() . " installed</li>\n";
306 error_reporting( 0 );
307 $phpdatabases = array();
308 foreach (array_keys($ourdb) as $db) {
309 $compname = $ourdb[$db]['compile
'];
310 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
311 array_push($phpdatabases, $db);
312 $ourdb[$db]['havedriver
'] = 1;
315 error_reporting( E_ALL );
317 if (!$phpdatabases) {
318 print "Could not find a suitable database driver!<ul>";
319 foreach (array_keys($ourdb) AS $db) {
320 $comp = $ourdb[$db]['compile
'];
321 $full = $ourdb[$db]['fullname
'];
322 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
323 ."or install the $comp.so module</li>\n";
325 dieout( "</ul></ul>" );
328 print "<li>Found database drivers for:";
330 foreach (array_keys($ourdb) AS $db) {
331 if ($ourdb[$db]['havedriver
']) {
332 if ( $DefaultDBtype == '' ) {
333 $DefaultDBtype = $db;
335 print " ".$ourdb[$db]['fullname
'];
340 if( wfIniGetBool( "register_globals" ) ) {
343 <div style="font-size:110%">
344 <strong class="error">Warning:</strong>
345 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
347 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
354 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
356 ?
><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
>
357 This option corrupts data input unpredictably
; you cannot install
or use
358 MediaWiki unless this option is disabled
.
362 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
364 ?
><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
>
365 This option corrupts data input unpredictably
; you cannot install
or use
366 MediaWiki unless this option is disabled
.
370 if( wfIniGetBool( "mbstring.func_overload" ) ) {
372 ?
><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
>
373 This option causes errors
and may corrupt data unpredictably
;
374 you cannot install
or use MediaWiki unless this option is disabled
.
378 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
380 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
381 This option causes horrible bugs with MediaWiki
; you cannot install
or use
382 MediaWiki unless this option is disabled
.
388 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
391 if( wfIniGetBool( "safe_mode" ) ) {
392 $conf->safeMode
= true;
394 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
395 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
396 You may have problems caused by this
, particularly
if using image uploads
.
400 $conf->safeMode
= false;
403 $sapi = php_sapi_name();
404 print "<li>PHP server API is $sapi; ";
405 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
406 if( $wgUsePathInfo ) {
407 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
409 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
413 $conf->xml
= function_exists( "utf8_encode" );
415 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
417 dieout( "PHP's XML module is missing; the wiki requires functions in
418 this module and won't work in this configuration.
419 If you're running Mandrake, install the php-xml package." );
422 # Check for session support
423 if( !function_exists( 'session_name' ) )
424 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
426 # session.save_path doesn't *have* to be set, but if it is, and it's
427 # not valid/writable/etc. then it can cause problems
428 $sessionSavePath = mw_get_session_save_path();
429 $ssp = htmlspecialchars( $sessionSavePath );
430 # Warn the user if it's not set, but let them proceed
431 if( !$sessionSavePath ) {
432 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
433 has not been set in PHP.ini. If the default value causes problems with
434 saving session data, set it to a valid path which is read/write/execute
435 for the user your web server is running under.</li>";
436 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
437 # All good? Let the user know
438 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
440 # Something not right? Warn the user, but let them proceed
441 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
442 appears to be invalid or is not writable. PHP needs to be able to save data to
443 this location for correct session operation.</li>";
446 # Check for PCRE support
447 if( !function_exists( 'preg_match' ) )
448 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
449 Perl-compatible regular expression functions." );
451 $memlimit = ini_get( "memory_limit" );
452 $conf->raiseMemory
= false;
453 if( empty( $memlimit ) ||
$memlimit == -1 ) {
454 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
456 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
457 $n = intval( $memlimit );
458 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
459 $n = intval( $m[1] * (1024*1024) );
461 if( $n < 20*1024*1024 ) {
462 print "Attempting to raise limit to 20M... ";
463 if( false === ini_set( "memory_limit", "20M" ) ) {
464 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
466 $conf->raiseMemory
= true;
473 $conf->turck
= function_exists( 'mmcache_get' );
474 if ( $conf->turck
) {
475 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
478 $conf->xcache
= function_exists( 'xcache_get' );
480 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
482 $conf->apc
= function_exists('apc_fetch');
484 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
487 $conf->eaccel
= function_exists( 'eaccelerator_get' );
488 if ( $conf->eaccel
) {
489 $conf->turck
= 'eaccelerator';
490 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
493 $conf->dba
= function_exists( 'dba_open' );
495 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
496 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
497 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
498 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
499 cannot use these for object caching.</li>' );
502 $conf->diff3
= false;
503 $diff3locations = array_merge(
510 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
511 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
513 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
514 foreach ($diff3locations as $loc) {
515 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
516 if ($exe !== false) {
523 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
525 print "<li>GNU diff3 not found.</li>";
527 $conf->ImageMagick
= false;
528 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
529 foreach( $imcheck as $dir ) {
530 $im = "$dir/convert";
531 if( @file_exists
( $im ) ) {
532 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
533 $conf->ImageMagick
= $im;
538 $conf->HaveGD
= function_exists( "imagejpeg" );
539 if( $conf->HaveGD
) {
540 print "<li>Found GD graphics library built-in";
541 if( !$conf->ImageMagick
) {
542 print ", image thumbnailing will be enabled if you enable uploads";
546 if( !$conf->ImageMagick
) {
547 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
551 $conf->IP
= dirname( dirname( __FILE__
) );
552 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
555 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
556 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
557 // to get the path to the current script... hopefully it's reliable. SIGH
558 $path = ($_SERVER["PHP_SELF"] === '')
559 ?
$_SERVER["SCRIPT_NAME"]
560 : $_SERVER["PHP_SELF"];
562 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
563 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
567 // We may be installing from *.php5 extension file, if so, print message
568 $conf->ScriptExtension
= '.php';
569 if (defined('MW_INSTALL_PHP5_EXT')) {
570 $conf->ScriptExtension
= '.php5';
571 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
573 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
577 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
578 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
580 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
581 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
583 : $_SERVER["SERVER_ADMIN"];
584 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
585 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
589 $conf->DBserver
= importPost( "DBserver", "localhost" );
590 $conf->DBname
= importPost( "DBname", "wikidb" );
591 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
592 $conf->DBpassword
= importPost( "DBpassword" );
593 $conf->DBpassword2
= importPost( "DBpassword2" );
594 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
595 $conf->SysopPass
= importPost( "SysopPass" );
596 $conf->SysopPass2
= importPost( "SysopPass2" );
597 $conf->RootUser
= importPost( "RootUser", "root" );
598 $conf->RootPW
= importPost( "RootPW", "" );
599 $useRoot = importCheck( 'useroot', false );
600 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
603 $conf->DBprefix
= importPost( "DBprefix" );
605 importPost( "DBschema", "mysql4" ),
606 importPost( "DBengine", "InnoDB" ) );
608 ## Postgres specific:
609 $conf->DBport
= importPost( "DBport", "5432" );
610 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
611 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
614 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
616 /* Check for validity */
619 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
620 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
622 if( $conf->DBuser
== "" ) {
623 $errs["DBuser"] = "Must not be blank";
625 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
626 $errs["DBuser"] = "Username too long";
628 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
629 $errs["DBpassword"] = "Must not be blank";
631 if( $conf->DBpassword
!= $conf->DBpassword2
) {
632 $errs["DBpassword2"] = "Passwords don't match!";
634 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
635 $errs["DBprefix"] = "Invalid table prefix";
638 error_reporting( E_ALL
);
641 * Initialise $wgLang and $wgContLang to something so we can
642 * call case-folding methods. Per Brion, this is English for
643 * now, although we could be clever and initialise to the
644 * user-selected language.
646 $wgContLang = Language
::factory( 'en' );
647 $wgLang = $wgContLang;
650 * We're messing about with users, so we need a stub
651 * authentication plugin...
653 $wgAuth = new AuthPlugin();
656 * Validate the initial administrator account; username,
657 * password checks, etc.
659 if( $conf->SysopName
) {
660 # Check that the user can be created
661 $u = User
::newFromName( $conf->SysopName
);
662 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
663 # Various password checks
664 if( $conf->SysopPass
!= '' ) {
665 if( $conf->SysopPass
== $conf->SysopPass2
) {
666 if( !$u->isValidPassword( $conf->SysopPass
) ) {
667 $errs['SysopPass'] = "Bad password";
670 $errs['SysopPass2'] = "Passwords don't match";
673 $errs['SysopPass'] = "Cannot be blank";
677 $errs['SysopName'] = "Bad username";
681 $conf->License
= importRequest( "License", "none" );
682 if( $conf->License
== "gfdl" ) {
683 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
684 $conf->RightsText
= "GNU Free Documentation License 1.2";
685 $conf->RightsCode
= "gfdl";
686 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
687 } elseif( $conf->License
== "none" ) {
688 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
690 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
691 $conf->RightsText
= importRequest( "RightsText", "" );
692 $conf->RightsCode
= importRequest( "RightsCode", "" );
693 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
696 $conf->Shm
= importRequest( "Shm", "none" );
697 $conf->MCServers
= importRequest( "MCServers" );
699 /* Test memcached servers */
701 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
702 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
703 foreach ( $conf->MCServerArray
as $server ) {
704 $error = testMemcachedServer( $server );
706 $errs["MCServers"] = $error;
710 } else if ( $conf->Shm
== 'memcached' ) {
711 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
714 /* default values for installation */
715 $conf->Email
= importRequest("Email", "email_enabled");
716 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
717 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
718 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
720 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
721 do { /* So we can 'continue' to end prematurely */
722 $conf->Root
= ($conf->RootPW
!= "");
724 /* Load up the settings and get installin' */
725 $local = writeLocalSettings( $conf );
726 echo "<li style=\"list-style: none\">\n";
727 echo "<p><b>Generating configuration file...</b></p>\n";
730 $wgCommandLineMode = false;
732 $ok = eval( $local );
733 if( $ok === false ) {
734 dieout( "Errors in generated configuration; " .
735 "most likely due to a bug in the installer... " .
736 "Config file was: " .
738 htmlspecialchars( $local ) .
742 $conf->DBtypename
= '';
743 foreach (array_keys($ourdb) as $db) {
744 if ($conf->DBtype
=== $db)
745 $conf->DBtypename
= $ourdb[$db]['fullname'];
747 if ( ! strlen($conf->DBtype
)) {
748 $errs["DBpicktype"] = "Please choose a database type";
752 if (! $conf->DBtypename
) {
753 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
756 print "<li>Database type: {$conf->DBtypename}</li>\n";
757 $dbclass = 'Database'.ucfirst($conf->DBtype
);
758 $wgDBtype = $conf->DBtype
;
759 $wgDBadminuser = "root";
760 $wgDBadminpassword = $conf->RootPW
;
763 $wgDBprefix = $conf->DBprefix
;
765 ## Postgres specific:
766 $wgDBport = $conf->DBport
;
767 $wgDBmwschema = $conf->DBmwschema
;
768 $wgDBts2schema = $conf->DBts2schema
;
770 $wgCommandLineMode = true;
771 if (! defined ( 'STDERR' ) )
772 define( 'STDERR', fopen("php://stderr", "wb"));
773 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
774 require_once( "$IP/includes/Setup.php" );
777 $wgTitle = Title
::newFromText( "Installation script" );
778 error_reporting( E_ALL
);
779 print "<li>Loading class: $dbclass";
782 if( $conf->DBtype
== 'mysql' ) {
783 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
784 if( $mysqlOldClient ) {
785 print "<li><b>PHP is linked with old MySQL client libraries. If you are
786 using a MySQL 4.1 server and have problems connecting to the database,
787 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
788 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
790 $ok = true; # Let's be optimistic
792 # Decide if we're going to use the superuser or the regular database user
793 $conf->Root
= $useRoot;
795 $db_user = $conf->RootUser
;
796 $db_pass = $conf->RootPW
;
798 $db_user = $wgDBuser;
799 $db_pass = $wgDBpassword;
803 echo( "<li>Attempting to connect to database server as $db_user..." );
804 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
806 # Check the connection and respond to errors
807 if( $wgDatabase->isOpen() ) {
810 $wgDBadminuser = $db_user;
811 $wgDBadminpassword = $db_pass;
812 echo( "success.</li>\n" );
813 $wgDatabase->ignoreErrors( true );
814 $myver = $wgDatabase->getServerVersion();
816 # There were errors, report them and back out
818 $errno = mysql_errno();
819 $errtx = htmlspecialchars( mysql_error() );
823 echo( "failed due to authentication errors. Check passwords.</li>" );
825 # The superuser details are wrong
826 $errs["RootUser"] = "Check username";
827 $errs["RootPW"] = "and password";
829 # The regular user details are wrong
830 $errs["DBuser"] = "Check username";
831 $errs["DBpassword"] = "and password";
837 # General connection problem
838 echo( "failed with error [$errno] $errtx.</li>\n" );
839 $errs["DBserver"] = "Connection failed";
844 if( !$ok ) { continue; }
847 error_reporting( E_ALL
);
849 ## Possible connect as a superuser
850 if( $useRoot && $conf->DBtype
!= 'sqlite' ) {
851 $wgDBsuperuser = $conf->RootUser
;
852 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
853 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
854 if (!$wgDatabase->isOpen()) {
855 print " error: " . $wgDatabase->lastError() . "</li>\n";
856 $errs["DBserver"] = "Could not connect to database as superuser";
857 $errs["RootUser"] = "Check username";
858 $errs["RootPW"] = "and password";
861 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
863 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
864 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
865 if (!$wgDatabase->isOpen()) {
866 print " error: " . $wgDatabase->lastError() . "</li>\n";
868 $myver = $wgDatabase->getServerVersion();
870 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
873 if ( !$wgDatabase->isOpen() ) {
874 $errs["DBserver"] = "Couldn't connect to database";
878 print "<li>Connected to $myver";
879 if ($conf->DBtype
== 'mysql') {
880 if( version_compare( $myver, "4.0.14" ) < 0 ) {
881 dieout( " -- mysql 4.0.14 or later required. Aborting." );
883 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
884 if( $mysqlNewAuth && $mysqlOldClient ) {
885 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
886 to old client libraries; if you have trouble with authentication, see
887 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
888 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
891 if( $mysqlNewAuth ) {
892 print "; enabling MySQL 4.1/5.0 charset mode";
894 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
895 but older version detected; will likely fail.</b>";
900 @$sel = $wgDatabase->selectDB( $wgDBname );
902 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
904 $err = mysql_errno();
905 $databaseSafe = htmlspecialchars( $wgDBname );
906 if( $err == 1102 /* Invalid database name */ ) {
907 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
909 } elseif( $err != 1049 /* Database doesn't exist */ ) {
910 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
911 print htmlspecialchars( mysql_error() ) . "</li></ul>";
914 print "<li>Attempting to create database...</li>";
915 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
917 print "<li>Couldn't create database <tt>" .
918 htmlspecialchars( $wgDBname ) .
919 "</tt>; try with root access or check your username/pass.</li>\n";
920 $errs["RootPW"] = "<- Enter";
923 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
925 $wgDatabase->selectDB( $wgDBname );
927 else if ($conf->DBtype
== 'postgres') {
928 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
929 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
933 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
934 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
936 if ( $conf->DBtype
== 'mysql') {
937 # Determine existing default character set
938 if ( $wgDatabase->tableExists( "revision" ) ) {
939 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
940 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
941 $row = $wgDatabase->fetchObject( $res );
943 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
944 $existingSchema = false;
945 $existingEngine = false;
947 if ( preg_match( '/^latin1/', $row->Collation
) ) {
948 $existingSchema = 'mysql4';
949 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
950 $existingSchema = 'mysql5';
951 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
952 $existingSchema = 'mysql5-binary';
954 $existingSchema = false;
955 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
957 if ( isset( $row->Engine
) ) {
958 $existingEngine = $row->Engine
;
960 $existingEngine = $row->Type
;
963 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
964 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
965 "but the existing database has the $existingSchema schema. This upgrade script ".
966 "can't convert it, so it will remain $existingSchema.</li>\n";
967 $conf->setSchema( $existingSchema, $conf->DBengine
);
969 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
970 print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
971 "engine, but the existing database uses the $existingEngine engine. This upgrade " .
972 "script can't convert it, so it will remain $existingEngine.</li>\n";
973 $conf->setSchema( $conf->DBschema
, $existingEngine );
977 # Create user if required
979 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
980 if ( $conn->isOpen() ) {
981 print "<li>DB user account ok</li>\n";
984 print "<li>Granting user permissions...";
985 if( $mysqlOldClient && $mysqlNewAuth ) {
986 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>";
989 dbsource( "../maintenance/users.sql", $wgDatabase );
993 print "</ul><pre>\n";
999 print "<ul><li>Finished update checks.</li>\n";
1001 # Determine available storage engines if possible
1002 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1003 $res = $wgDatabase->query( 'SHOW ENGINES' );
1005 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1006 if ( $row->Engine
== $conf->DBengine
) {
1011 $wgDatabase->freeResult( $res );
1012 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1013 echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
1014 "using MyISAM instead</li>\n";
1015 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1019 # FIXME: Check for errors
1020 print "<li>Creating tables...";
1021 if ($conf->DBtype
== 'mysql') {
1022 dbsource( "../maintenance/tables.sql", $wgDatabase );
1023 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1024 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1025 $wgDatabase->setup_database();
1028 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1032 print " done.</li>\n";
1034 print "<li>Initializing statistics...</li>\n";
1035 $wgDatabase->insert( 'site_stats',
1036 array ( 'ss_row_id' => 1,
1037 'ss_total_views' => 0,
1038 'ss_total_edits' => 1, # Main page first edit
1039 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1040 'ss_total_pages' => 1, # Main page
1041 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1042 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1043 'ss_images' => 0 ) );
1045 # Set up the "regular user" account *if we can, and if we need to*
1046 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1048 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1049 if( $wgDatabase2->isOpen() ) {
1050 # Nope, just close the test connection and continue
1051 $wgDatabase2->close();
1052 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
1054 # Yes, so run the grants
1055 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
1056 dbsource( "../maintenance/users.sql", $wgDatabase );
1057 echo( "success.</li>\n" );
1061 if( $conf->SysopName
) {
1062 $u = User
::newFromName( $conf->getSysopName() );
1064 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1066 else if ( 0 == $u->idForName() ) {
1067 $u->addToDatabase();
1068 $u->setPassword( $conf->getSysopPass() );
1071 $u->addGroup( "sysop" );
1072 $u->addGroup( "bureaucrat" );
1074 print "<li>Created sysop account <tt>" .
1075 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1077 print "<li>Could not create user - already exists!</li>\n";
1080 print "<li>Skipped sysop account creation, no name given.</li>\n";
1083 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1084 $article = new Article( $titleobj );
1085 $newid = $article->insertOn( $wgDatabase );
1086 $revision = new Revision( array(
1088 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1091 'user_text' => 'MediaWiki default',
1093 $revid = $revision->insertOn( $wgDatabase );
1094 $article->updateRevisionOn( $wgDatabase, $revision );
1097 /* Write out the config file now that all is well */
1098 print "<li style=\"list-style: none\">\n";
1099 print "<p>Creating LocalSettings.php...</p>\n\n";
1100 $localSettings = "<" . "?php$endl$local";
1101 // Fix up a common line-ending problem (due to CVS on Windows)
1102 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1103 $f = fopen( "LocalSettings.php", 'xt' );
1106 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" .
1107 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1108 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1110 if(fwrite( $f, $localSettings ) ) {
1112 print "</li></ul><hr/>\n";
1113 writeSuccessMessage();
1116 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");
1117 print "</li></ul>\n";
1128 if( count( $errs ) ) {
1129 /* Display options form */
1131 if( $conf->posted
) {
1132 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1136 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1139 <h2
>Site config
</h2
>
1141 <div
class="config-section">
1142 <div
class="config-input">
1144 aField( $conf, "Sitename", "Wiki name:" );
1147 <p
class="config-desc">
1148 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1149 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1152 <div
class="config-input">
1154 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1157 <p
class="config-desc">
1158 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
.
1161 <div
class="config-input">
1162 <label
class='column' for="LanguageCode">Language
:</label
>
1163 <select id
="LanguageCode" name
="LanguageCode">
1166 $list = getLanguageList();
1167 foreach( $list as $code => $name ) {
1168 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1169 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1174 <p
class="config-desc">
1175 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1178 <div
class="config-input">
1179 <label
class='column'>Copyright
/license
:</label
>
1182 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1183 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1185 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1186 $partner = "MediaWiki";
1187 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1188 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1189 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1190 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1191 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1193 <?php
if( $conf->License
== "cc" ) { ?
>
1195 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1196 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1197 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1198 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1204 <p
class="config-desc">
1205 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1209 <div
class="config-input">
1210 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1212 <div
class="config-input">
1213 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1215 <div
class="config-input">
1216 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1218 <p
class="config-desc">
1219 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1220 A
new account will be added only when creating a
new wiki database
.
1222 The password cannot be the same
as the username
.
1225 <div
class="config-input">
1226 <label
class='column'>Object caching
:</label
>
1229 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1231 if ( $conf->turck
) {
1233 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1236 if( $conf->xcache
) {
1238 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1243 aField( $conf, "Shm", "APC", "radio", "apc" );
1246 if ( $conf->eaccel
) {
1248 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1253 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1257 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1259 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1261 <p
class="config-desc">
1262 An
object caching system such
as memcached will provide a significant performance boost
,
1263 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1265 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1266 these should not be used
if the wiki will be running on multiple application servers
.
1268 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1269 recommended
for testing
.
1273 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1275 <div
class="config-section">
1276 <div
class="config-input">
1277 <label
class='column'>E
-mail
features (global):</label
>
1279 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1280 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1283 <p
class="config-desc">
1284 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1285 if sending mail doesn
't work on your server.
1288 <div class="config-input">
1289 <label class='column
'>User-to-user e-mail:</label>
1291 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1292 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1295 <p class="config-desc">
1296 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.
1298 <div class="config-input">
1299 <label class='column
'>E-mail notification about changes:</label>
1301 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1302 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1303 <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>
1306 <div class="config-desc">
1308 For this feature to work, an e-mail address must be present for the user account, and the notification
1309 options in the user's preferences must be enabled
. Also note the
1310 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1312 <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
>
1315 <div
class="config-input">
1316 <label
class='column'>E
-mail address authentication
:</label
>
1318 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1319 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1322 <div
class="config-desc">
1323 <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
1324 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1329 <h2
>Database config
</h2
>
1331 <div
class="config-section">
1332 <div
class="config-input">
1333 <label
class='column'>Database type
:</label
>
1334 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1335 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1338 <div
class="config-input" style
="clear:left"><?php
1339 aField( $conf, "DBserver", "Database host:" );
1341 <p
class="config-desc">
1342 If your database server isn
't on your web server, enter the name or IP address here.
1345 <div class="config-input"><?php
1346 aField( $conf, "DBname", "Database name:" );
1348 <div class="config-input"><?php
1349 aField( $conf, "DBuser", "DB username:" );
1351 <div class="config-input"><?php
1352 aField( $conf, "DBpassword", "DB password:", "password" );
1354 <div class="config-input"><?php
1355 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1357 <p class="config-desc">
1358 If you only have a single user account and database available,
1359 enter those here. If you have database root access (see below)
1360 you can specify new accounts/databases to be created. This account
1361 will not be created if it pre-exists. If this is the case, ensure that it
1362 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1365 <div class="config-input">
1366 <label class="column">Superuser account:</label>
1367 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1368 <label for="useroot">Use superuser account</label>
1370 <div class="config-input">
1372 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1375 <div class="config-input">
1377 aField( $conf, "RootPW", "Superuser password:", "password" );
1381 <p class="config-desc">
1382 If the database user specified above does not exist, or does not have access to create
1383 the database (if needed) or tables within it, please check the box and provide details
1384 of a superuser account, such as <strong>root</strong>, which does.
1387 <?php database_switcher('mysql
'); ?>
1388 <div class="config-input"><?php
1389 aField( $conf, "DBprefix", "Database table prefix:" );
1391 <div class="config-desc">
1392 <p>If you need to share one database between multiple wikis, or
1393 between MediaWiki and another web application, you may choose to
1394 add a prefix to all the table names to avoid conflicts.</p>
1396 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1399 <div class="config-input"><label class="column">Storage Engine</label>
1400 <div>Select one:</div>
1402 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1403 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1406 <p class="config-desc">
1407 InnoDB is best for public web installations, since it has good concurrency
1408 support. MyISAM may be faster in single-user installations. MyISAM databases
1409 tend to get corrupted more often than InnoDB databases.
1411 <div class="config-input"><label class="column">Database character set</label>
1412 <div>Select one:</div>
1414 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1415 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1416 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1419 <p class="config-desc">
1420 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1421 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1422 cause things to break. <b>If upgrading an older installation, leave
1423 in backwards-compatible mode.</b>
1427 <?php database_switcher('postgres
'); ?>
1428 <div class="config-input"><?php
1429 aField( $conf, "DBport", "Database port:" );
1431 <div class="config-input"><?php
1432 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1434 <div class="config-input"><?php
1435 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1437 <div class="config-desc">
1438 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1439 so it is recommended that you create a new user. The above schemas are generally correct:
1440 only change them if you are sure you need to.</p>
1444 <?php database_switcher('sqlite
'); ?>
1445 <div class="config-desc">
1446 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1448 <div class="config-input"><?php
1449 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1451 <div class="config-desc">
1452 <p>SQLite stores table data into files in the filesystem.
1453 If you do not provide an explicit path, a "data" directory in
1454 the parent of your document root will be used.</p>
1456 <p>This directory must exist and be writable by the web server.</p>
1460 <?php database_switcher('mssql
'); ?>
1461 <div class="config-input"><?php
1462 aField( $conf, "DBprefix", "Database table prefix:" );
1464 <div class="config-desc">
1465 <p>If you need to share one database between multiple wikis, or
1466 between MediaWiki and another web application, you may choose to
1467 add a prefix to all the table names to avoid conflicts.</p>
1469 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1473 <div class="config-input" style="padding:2em 0 3em">
1474 <label class='column
'> </label>
1475 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1480 <script type="text/javascript">
1481 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1483 ## If they passed in a root user name, don't populate it on page load
1484 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1493 /* -------------------------------------------------------------------------------------- */
1494 function writeSuccessMessage() {
1495 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1496 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1498 <div class="success-box">
1499 <p>Installation successful!</p>
1500 <p>To complete the installation, please do the following:
1502 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1503 <li>Upload it to the parent directory</li>
1504 <li>Delete config/LocalSettings.php</li>
1505 <li>Start using <a href='../$script'>your wiki</a>!
1507 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1508 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1509 which means that anyone on the same server can read your database password! Downloading
1510 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1515 <div class="success-box">
1517 <span class="success-message">Installation successful!</span>
1518 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1519 <a href="../$script"> this link</a> to your wiki.</p>
1520 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1521 prevent other users on the server reading passwords and altering configuration data.</p>
1528 function escapePhpString( $string ) {
1529 if ( is_array( $string ) ||
is_object( $string ) ) {
1532 return strtr( $string,
1543 function writeLocalSettings( $conf ) {
1544 $conf->PasswordSender
= $conf->EmergencyContact
;
1545 $magic = ($conf->ImageMagick ?
"" : "# ");
1546 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1547 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1548 $hashedUploads = $conf->safeMode ?
'' : '# ';
1550 switch ( $conf->Shm
) {
1552 $cacheType = 'CACHE_MEMCACHED';
1553 $mcservers = var_export( $conf->MCServerArray
, true );
1559 $cacheType = 'CACHE_ACCEL';
1560 $mcservers = 'array()';
1563 $cacheType = 'CACHE_DBA';
1564 $mcservers = 'array()';
1567 $cacheType = 'CACHE_NONE';
1568 $mcservers = 'array()';
1571 if ( $conf->Email
== 'email_enabled' ) {
1572 $enableemail = 'true';
1573 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1574 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1575 switch ( $conf->Enotif
) {
1576 case 'enotif_usertalk':
1577 $enotifusertalk = 'true';
1578 $enotifwatchlist = 'false';
1580 case 'enotif_allpages':
1581 $enotifusertalk = 'true';
1582 $enotifwatchlist = 'true';
1585 $enotifusertalk = 'false';
1586 $enotifwatchlist = 'false';
1589 $enableuseremail = 'false';
1590 $enableemail = 'false';
1591 $eauthent = 'false';
1592 $enotifusertalk = 'false';
1593 $enotifwatchlist = 'false';
1596 $file = @fopen
( "/dev/urandom", "r" );
1598 $secretKey = bin2hex( fread( $file, 32 ) );
1602 for ( $i=0; $i<8; $i++
) {
1603 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1605 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1608 # Add slashes to strings for double quoting
1609 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1610 if( $conf->License
== 'gfdl' ) {
1611 # Needs literal string interpolation for the current style path
1612 $slconf['RightsIcon'] = $conf->RightsIcon
;
1615 if( $conf->DBtype
== 'mysql' ) {
1617 "# MySQL specific settings
1618 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1620 # MySQL table options to use during installation or update
1621 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1623 # Experimental charset support for MySQL 4.1/5.0.
1624 \$wgDBmysql5 = {$conf->DBmysql5};";
1625 } elseif( $conf->DBtype
== 'postgres' ) {
1627 "# Postgres specific settings
1628 \$wgDBport = \"{$slconf['DBport']}\";
1629 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1630 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1631 } elseif( $conf->DBtype
== 'sqlite' ) {
1633 "# SQLite-specific settings
1634 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1642 # This file was automatically generated by the MediaWiki installer.
1643 # If you make manual changes, please keep track in case you need to
1644 # recreate them later.
1646 # See includes/DefaultSettings.php for all configurable settings
1647 # and their default values, but don't forget to make changes in _this_
1650 # Further documentation for configuration settings may be found at:
1651 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1653 # If you customize your file layout, set \$IP to the directory that contains
1654 # the other MediaWiki files. It will be used as a base to locate files.
1655 if( defined( 'MW_INSTALL_PATH' ) ) {
1656 \$IP = MW_INSTALL_PATH;
1658 \$IP = dirname( __FILE__ );
1661 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1662 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1664 require_once( \"\$IP/includes/DefaultSettings.php\" );
1666 # If PHP's memory limit is very low, some operations may fail.
1667 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1669 if ( \$wgCommandLineMode ) {
1670 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1671 die( \"This script must be run from the command line\\n\" );
1674 ## Uncomment this to disable output compression
1675 # \$wgDisableOutputCompression = true;
1677 \$wgSitename = \"{$slconf['Sitename']}\";
1679 ## The URL base path to the directory containing the wiki;
1680 ## defaults for all runtime URL paths are based off of this.
1681 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1682 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1684 ## For more information on customizing the URLs please see:
1685 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1687 \$wgEnableEmail = $enableemail;
1688 \$wgEnableUserEmail = $enableuseremail;
1690 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1691 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1693 ## UPO means: this is also a user preference option
1694 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1695 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1696 \$wgEmailAuthentication = $eauthent;
1698 \$wgDBtype = \"{$slconf['DBtype']}\";
1699 \$wgDBserver = \"{$slconf['DBserver']}\";
1700 \$wgDBname = \"{$slconf['DBname']}\";
1701 \$wgDBuser = \"{$slconf['DBuser']}\";
1702 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1706 ## Shared memory settings
1707 \$wgMainCacheType = $cacheType;
1708 \$wgMemCachedServers = $mcservers;
1710 ## To enable image uploads, make sure the 'images' directory
1711 ## is writable, then set this to true:
1712 \$wgEnableUploads = false;
1713 {$magic}\$wgUseImageMagick = true;
1714 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1716 ## If you want to use image uploads under safe mode,
1717 ## create the directories images/archive, images/thumb and
1718 ## images/temp, and make them all writable. Then uncomment
1719 ## this, if it's not already uncommented:
1720 {$hashedUploads}\$wgHashedUploadDirectory = false;
1722 ## If you have the appropriate support software installed
1723 ## you can enable inline LaTeX equations:
1726 \$wgLocalInterwiki = \$wgSitename;
1728 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1730 \$wgProxyKey = \"$secretKey\";
1732 ## Default skin: you can change the default skin. Use the internal symbolic
1733 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1734 \$wgDefaultSkin = 'monobook';
1736 ## For attaching licensing metadata to pages, and displaying an
1737 ## appropriate copyright notice / icon. GNU Free Documentation
1738 ## License and Creative Commons licenses are supported so far.
1739 {$rights}\$wgEnableCreativeCommonsRdf = true;
1740 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1741 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1742 \$wgRightsText = \"{$slconf['RightsText']}\";
1743 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1744 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1746 \$wgDiff3 = \"{$slconf['diff3']}\";
1748 # When you make changes to this configuration file, this will make
1749 # sure that cached pages are cleared.
1750 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1751 "; ## End of setting the $localsettings string
1753 // Keep things in Unix line endings internally;
1754 // the system will write out as local text type.
1755 return str_replace( "\r\n", "\n", $localsettings );
1758 function dieout( $text ) {
1759 die( $text . "\n\n</body>\n</html>" );
1762 function importVar( &$var, $name, $default = "" ) {
1763 if( isset( $var[$name] ) ) {
1764 $retval = $var[$name];
1765 if ( get_magic_quotes_gpc() ) {
1766 $retval = stripslashes( $retval );
1774 function importPost( $name, $default = "" ) {
1775 return importVar( $_POST, $name, $default );
1778 function importCheck( $name ) {
1779 return isset( $_POST[$name] );
1782 function importRequest( $name, $default = "" ) {
1783 return importVar( $_REQUEST, $name, $default );
1788 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1791 $xtype = "type=\"$type\"";
1797 $nolabel = ($type == "radio") ||
($type == "hidden");
1799 if ($type == 'radio')
1800 $id .= $radioCount++
;
1805 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1808 if( $type == "radio" && $value == $conf->$field ) {
1809 $checked = "checked='checked'";
1813 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1815 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1818 if( $type == "radio" ) {
1819 echo htmlspecialchars( $value );
1821 echo htmlspecialchars( $conf->$field );
1827 echo " $text</label>\n";
1831 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1834 function getLanguageList() {
1835 global $wgLanguageNames, $IP;
1836 if( !isset( $wgLanguageNames ) ) {
1837 require_once( "$IP/languages/Names.php" );
1842 $d = opendir( "../languages/messages" );
1843 /* In case we are called from the root directory */
1845 $d = opendir( "languages/messages");
1846 while( false !== ($f = readdir( $d ) ) ) {
1848 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1849 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1850 if( isset( $wgLanguageNames[$code] ) ) {
1851 $name = $code . ' - ' . $wgLanguageNames[$code];
1855 $codes[$code] = $name;
1863 #Check for location of an executable
1864 # @param string $loc single location to check
1865 # @param array $names filenames to check for.
1866 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1867 function locate_executable($loc, $names, $versioninfo = false) {
1868 if (!is_array($names))
1869 $names = array($names);
1871 foreach ($names as $name) {
1872 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1873 if (@file_exists
($command)) {
1877 $file = str_replace('$1', $command, $versioninfo[0]);
1878 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1885 # Test a memcached server
1886 function testMemcachedServer( $server ) {
1887 $hostport = explode(":", $server);
1890 if ( !function_exists( 'fsockopen' ) ) {
1891 $errstr = "Can't connect to memcached, fsockopen() not present";
1893 if ( !$errstr && count( $hostport ) != 2 ) {
1894 $errstr = 'Please specify host and port';
1897 list( $host, $port ) = $hostport;
1901 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1902 if ( $fp === false ) {
1903 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1907 $command = "version\r\n";
1908 $bytes = fwrite( $fp, $command );
1909 if ( $bytes != strlen( $command ) ) {
1910 $errstr = "Cannot write to memcached socket on $host:$port";
1914 $expected = "VERSION ";
1915 $response = fread( $fp, strlen( $expected ) );
1916 if ( $response != $expected ) {
1917 $errstr = "Didn't get correct memcached response from $host:$port";
1924 echo "<li>Connected to memcached on $host:$port successfully";
1929 function database_picker($conf) {
1932 foreach(array_keys($ourdb) as $db) {
1933 if ($ourdb[$db]['havedriver']) {
1935 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1942 function database_switcher($db) {
1944 $color = $ourdb[$db]['bgcolor'];
1945 $full = $ourdb[$db]['fullname'];
1946 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
1949 function printListItem( $item ) {
1950 print "<li>$item</li>";
1955 <div
class="license">
1957 <p
>This program is free software
; you can redistribute it
and/or modify
1958 it under the terms of the GNU General
Public License
as published by
1959 the Free Software Foundation
; either version
2 of the License
, or
1960 (at your option
) any later version
.</p
>
1962 <p
>This program is distributed in the hope that it will be useful
,
1963 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1964 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1965 GNU General
Public License
for more details
.</p
>
1967 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1968 along with this program
; if not
, write to the Free Software
1969 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1970 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1976 <div id
="column-one">
1977 <div
class="portlet" id
="p-logo">
1978 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1979 href
="http://www.mediawiki.org/"
1980 title
="Main Page"></a
>
1982 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1983 <div
class='portlet'><div
class='pBody'>
1985 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1986 <li
><a href
="../README">Readme
</a
></li
>
1987 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1988 <li
><a href
="../docs/">Documentation
</a
></li
>
1989 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1990 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
1992 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2008 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>