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'] = 'root';
77 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
80 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
81 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
82 <style type
="text/css">
84 @import
"../skins/monobook/main.css";
88 margin
: 1em
0 1em
2.5em
;
95 .config
-section label
.column
{
107 zoom
: 100%
; /* IE hack */
110 .config
-section
.config
-desc
{
112 margin
: 0 0 2em
18em
;
117 .iput
-text
, .iput
-password
{
124 background
-color
: #fff;
132 background
-color
: #FFF0F0;
133 border
: 2px solid red
;
141 list-style
-type
: none
;
142 list-style
-image
: none
;
159 span
.success
-message
{
169 <script type
="text/javascript">
172 <?php
foreach (array_keys($ourdb) as $db) {
173 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
178 function toggleDBarea(id
,defaultroot
) {
180 var dbarea
= document
.getElementById(id
);
181 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
182 var db
= document
.getElementById('RootUser');
184 <?php
foreach (array_keys($ourdb) as $db) {
185 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
194 <div id
="globalWrapper">
195 <div id
="column-content">
197 <div id
="bodyContent">
199 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
203 /* Check for existing configurations and bug out! */
205 if( file_exists( "../LocalSettings.php" ) ) {
206 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
207 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
209 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
212 if( file_exists( "./LocalSettings.php" ) ) {
213 writeSuccessMessage();
218 if( !is_writable( "." ) ) {
219 dieout( "<h2>Can't write config file, aborting</h2>
221 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
222 writable by the web server. Once configuration is done you'll move the created
223 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
224 then remove the <tt>config</tt> subdirectory entirely.</p>
226 <p>To make the directory writable on a Unix/Linux system:</p>
229 cd <i>/path/to/wiki</i>
233 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
237 require_once( "$IP/install-utils.inc" );
238 require_once( "$IP/maintenance/updaters.inc" );
241 function getEncoded( $data ) {
242 # removing latin1 support, no need...
245 function getSitename() { return $this->getEncoded( $this->Sitename
); }
246 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
247 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
249 function setSchema( $schema, $engine ) {
250 $this->DBschema
= $schema;
251 if ( !preg_match( '/^\w*$/', $engine ) ){
254 switch ( $this->DBschema
) {
256 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
257 $this->DBmysql5
= 'true';
259 case 'mysql5-binary':
260 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
261 $this->DBmysql5
= 'true';
264 $this->DBTableOptions
= "TYPE=$engine";
265 $this->DBmysql5
= 'false';
267 $this->DBengine
= $engine;
269 # Set the global for use during install
270 global $wgDBTableOptions;
271 $wgDBTableOptions = $this->DBTableOptions
;
279 <b
>Don
't forget security updates!</b> Keep an eye on the
280 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
281 release announcements mailing list</a>.
286 <h2>Checking environment...</h2>
287 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
288 <ul class="env-check">
292 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
293 $conf = new ConfigData;
295 install_version_checks();
296 $self = 'Installer
'; # Maintenance script name, to please Setup.php
298 print "<li>PHP " . phpversion() . " installed</li>\n";
300 error_reporting( 0 );
301 $phpdatabases = array();
302 foreach (array_keys($ourdb) as $db) {
303 $compname = $ourdb[$db]['compile
'];
304 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
305 array_push($phpdatabases, $db);
306 $ourdb[$db]['havedriver
'] = 1;
309 error_reporting( E_ALL );
311 if (!$phpdatabases) {
312 print "Could not find a suitable database driver!<ul>";
313 foreach (array_keys($ourdb) AS $db) {
314 $comp = $ourdb[$db]['compile
'];
315 $full = $ourdb[$db]['fullname
'];
316 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
317 ."or install the $comp.so module</li>\n";
319 dieout( "</ul></ul>" );
322 print "<li>Found database drivers for:";
324 foreach (array_keys($ourdb) AS $db) {
325 if ($ourdb[$db]['havedriver
']) {
326 if ( $DefaultDBtype == '' ) {
327 $DefaultDBtype = $db;
329 print " ".$ourdb[$db]['fullname
'];
334 if( wfIniGetBool( "register_globals" ) ) {
337 <div style="font-size:110%">
338 <strong class="error">Warning:</strong>
339 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
341 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
348 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
350 ?
><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
>
351 This option corrupts data input unpredictably
; you cannot install
or use
352 MediaWiki unless this option is disabled
.
356 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
358 ?
><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
>
359 This option corrupts data input unpredictably
; you cannot install
or use
360 MediaWiki unless this option is disabled
.
364 if( wfIniGetBool( "mbstring.func_overload" ) ) {
366 ?
><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
>
367 This option causes errors
and may corrupt data unpredictably
;
368 you cannot install
or use MediaWiki unless this option is disabled
.
372 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
374 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
375 This option causes horrible bugs with MediaWiki
; you cannot install
or use
376 MediaWiki unless this option is disabled
.
382 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
385 if( wfIniGetBool( "safe_mode" ) ) {
386 $conf->safeMode
= true;
388 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
389 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
390 You may have problems caused by this
, particularly
if using image uploads
.
394 $conf->safeMode
= false;
397 $sapi = php_sapi_name();
398 print "<li>PHP server API is $sapi; ";
399 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
400 if( $wgUsePathInfo ) {
401 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
403 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
407 $conf->xml
= function_exists( "utf8_encode" );
409 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
411 dieout( "PHP's XML module is missing; the wiki requires functions in
412 this module and won't work in this configuration.
413 If you're running Mandrake, install the php-xml package." );
416 # Check for session support
417 if( !function_exists( 'session_name' ) )
418 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
420 # session.save_path doesn't *have* to be set, but if it is, and it's
421 # not valid/writable/etc. then it can cause problems
422 $sessionSavePath = mw_get_session_save_path();
423 $ssp = htmlspecialchars( $sessionSavePath );
424 # Warn the user if it's not set, but let them proceed
425 if( !$sessionSavePath ) {
426 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
427 has not been set in PHP.ini. If the default value causes problems with
428 saving session data, set it to a valid path which is read/write/execute
429 for the user your web server is running under.</li>";
430 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
431 # All good? Let the user know
432 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
434 # Something not right? Warn the user, but let them proceed
435 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
436 appears to be invalid or is not writable. PHP needs to be able to save data to
437 this location for correct session operation.</li>";
440 # Check for PCRE support
441 if( !function_exists( 'preg_match' ) )
442 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
443 Perl-compatible regular expression functions." );
445 $memlimit = ini_get( "memory_limit" );
446 $conf->raiseMemory
= false;
447 if( empty( $memlimit ) ||
$memlimit == -1 ) {
448 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
450 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
451 $n = intval( $memlimit );
452 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
453 $n = intval( $m[1] * (1024*1024) );
455 if( $n < 20*1024*1024 ) {
456 print "Attempting to raise limit to 20M... ";
457 if( false === ini_set( "memory_limit", "20M" ) ) {
458 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
460 $conf->raiseMemory
= true;
467 $conf->turck
= function_exists( 'mmcache_get' );
468 if ( $conf->turck
) {
469 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
472 $conf->xcache
= function_exists( 'xcache_get' );
474 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
476 $conf->apc
= function_exists('apc_fetch');
478 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
481 $conf->eaccel
= function_exists( 'eaccelerator_get' );
482 if ( $conf->eaccel
) {
483 $conf->turck
= 'eaccelerator';
484 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
487 $conf->dba
= function_exists( 'dba_open' );
489 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
490 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
491 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
492 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
493 cannot use these for object caching.</li>' );
496 $conf->diff3
= false;
497 $diff3locations = array_merge(
504 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
505 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
507 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
508 foreach ($diff3locations as $loc) {
509 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
510 if ($exe !== false) {
517 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
519 print "<li>GNU diff3 not found.</li>";
521 $conf->ImageMagick
= false;
522 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
523 foreach( $imcheck as $dir ) {
524 $im = "$dir/convert";
525 if( @file_exists
( $im ) ) {
526 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
527 $conf->ImageMagick
= $im;
532 $conf->HaveGD
= function_exists( "imagejpeg" );
533 if( $conf->HaveGD
) {
534 print "<li>Found GD graphics library built-in";
535 if( !$conf->ImageMagick
) {
536 print ", image thumbnailing will be enabled if you enable uploads";
540 if( !$conf->ImageMagick
) {
541 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
545 $conf->IP
= dirname( dirname( __FILE__
) );
546 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
549 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
550 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
551 // to get the path to the current script... hopefully it's reliable. SIGH
552 $path = ($_SERVER["PHP_SELF"] === '')
553 ?
$_SERVER["SCRIPT_NAME"]
554 : $_SERVER["PHP_SELF"];
556 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
557 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
561 // We may be installing from *.php5 extension file, if so, print message
562 $conf->ScriptExtension
= '.php';
563 if (defined('MW_INSTALL_PHP5_EXT')) {
564 $conf->ScriptExtension
= '.php5';
565 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
567 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
571 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
572 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
574 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
575 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
577 : $_SERVER["SERVER_ADMIN"];
578 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
579 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
583 $conf->DBserver
= importPost( "DBserver", "localhost" );
584 $conf->DBname
= importPost( "DBname", "wikidb" );
585 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
586 $conf->DBpassword
= importPost( "DBpassword" );
587 $conf->DBpassword2
= importPost( "DBpassword2" );
588 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
589 $conf->SysopPass
= importPost( "SysopPass" );
590 $conf->SysopPass2
= importPost( "SysopPass2" );
591 $conf->RootUser
= importPost( "RootUser", "root" );
592 $conf->RootPW
= importPost( "RootPW", "" );
593 $useRoot = importCheck( 'useroot', false );
594 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
597 $conf->DBprefix
= importPost( "DBprefix" );
599 importPost( "DBschema", "mysql4" ),
600 importPost( "DBengine", "InnoDB" ) );
602 ## Postgres specific:
603 $conf->DBport
= importPost( "DBport", "5432" );
604 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
605 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
608 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
610 /* Check for validity */
613 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
614 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
616 if( $conf->DBuser
== "" ) {
617 $errs["DBuser"] = "Must not be blank";
619 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
620 $errs["DBuser"] = "Username too long";
622 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
623 $errs["DBpassword"] = "Must not be blank";
625 if( $conf->DBpassword
!= $conf->DBpassword2
) {
626 $errs["DBpassword2"] = "Passwords don't match!";
628 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
629 $errs["DBprefix"] = "Invalid table prefix";
632 error_reporting( E_ALL
);
635 * Initialise $wgLang and $wgContLang to something so we can
636 * call case-folding methods. Per Brion, this is English for
637 * now, although we could be clever and initialise to the
638 * user-selected language.
640 $wgContLang = Language
::factory( 'en' );
641 $wgLang = $wgContLang;
644 * We're messing about with users, so we need a stub
645 * authentication plugin...
647 $wgAuth = new AuthPlugin();
650 * Validate the initial administrator account; username,
651 * password checks, etc.
653 if( $conf->SysopName
) {
654 # Check that the user can be created
655 $u = User
::newFromName( $conf->SysopName
);
656 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
657 # Various password checks
658 if( $conf->SysopPass
!= '' ) {
659 if( $conf->SysopPass
== $conf->SysopPass2
) {
660 if( !$u->isValidPassword( $conf->SysopPass
) ) {
661 $errs['SysopPass'] = "Bad password";
664 $errs['SysopPass2'] = "Passwords don't match";
667 $errs['SysopPass'] = "Cannot be blank";
671 $errs['SysopName'] = "Bad username";
675 $conf->License
= importRequest( "License", "none" );
676 if( $conf->License
== "gfdl" ) {
677 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
678 $conf->RightsText
= "GNU Free Documentation License 1.2";
679 $conf->RightsCode
= "gfdl";
680 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
681 } elseif( $conf->License
== "none" ) {
682 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
684 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
685 $conf->RightsText
= importRequest( "RightsText", "" );
686 $conf->RightsCode
= importRequest( "RightsCode", "" );
687 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
690 $conf->Shm
= importRequest( "Shm", "none" );
691 $conf->MCServers
= importRequest( "MCServers" );
693 /* Test memcached servers */
695 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
696 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
697 foreach ( $conf->MCServerArray
as $server ) {
698 $error = testMemcachedServer( $server );
700 $errs["MCServers"] = $error;
704 } else if ( $conf->Shm
== 'memcached' ) {
705 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
708 /* default values for installation */
709 $conf->Email
= importRequest("Email", "email_enabled");
710 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
711 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
712 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
714 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
715 do { /* So we can 'continue' to end prematurely */
716 $conf->Root
= ($conf->RootPW
!= "");
718 /* Load up the settings and get installin' */
719 $local = writeLocalSettings( $conf );
720 echo "<li style=\"list-style: none\">\n";
721 echo "<p><b>Generating configuration file...</b></p>\n";
724 $wgCommandLineMode = false;
726 $ok = eval( $local );
727 if( $ok === false ) {
728 dieout( "Errors in generated configuration; " .
729 "most likely due to a bug in the installer... " .
730 "Config file was: " .
732 htmlspecialchars( $local ) .
736 $conf->DBtypename
= '';
737 foreach (array_keys($ourdb) as $db) {
738 if ($conf->DBtype
=== $db)
739 $conf->DBtypename
= $ourdb[$db]['fullname'];
741 if ( ! strlen($conf->DBtype
)) {
742 $errs["DBpicktype"] = "Please choose a database type";
746 if (! $conf->DBtypename
) {
747 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
750 print "<li>Database type: {$conf->DBtypename}</li>\n";
751 $dbclass = 'Database'.ucfirst($conf->DBtype
);
752 $wgDBtype = $conf->DBtype
;
753 $wgDBadminuser = "root";
754 $wgDBadminpassword = $conf->RootPW
;
757 $wgDBprefix = $conf->DBprefix
;
759 ## Postgres specific:
760 $wgDBport = $conf->DBport
;
761 $wgDBmwschema = $conf->DBmwschema
;
762 $wgDBts2schema = $conf->DBts2schema
;
764 $wgCommandLineMode = true;
765 if (! defined ( 'STDERR' ) )
766 define( 'STDERR', fopen("php://stderr", "wb"));
767 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
768 require_once( "$IP/includes/Setup.php" );
771 $wgTitle = Title
::newFromText( "Installation script" );
772 error_reporting( E_ALL
);
773 print "<li>Loading class: $dbclass";
776 if( $conf->DBtype
== 'mysql' ) {
777 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
778 if( $mysqlOldClient ) {
779 print "<li><b>PHP is linked with old MySQL client libraries. If you are
780 using a MySQL 4.1 server and have problems connecting to the database,
781 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
782 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
784 $ok = true; # Let's be optimistic
786 # Decide if we're going to use the superuser or the regular database user
787 $conf->Root
= $useRoot;
789 $db_user = $conf->RootUser
;
790 $db_pass = $conf->RootPW
;
792 $db_user = $wgDBuser;
793 $db_pass = $wgDBpassword;
797 echo( "<li>Attempting to connect to database server as $db_user..." );
798 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
800 # Check the connection and respond to errors
801 if( $wgDatabase->isOpen() ) {
804 $wgDBadminuser = $db_user;
805 $wgDBadminpassword = $db_pass;
806 echo( "success.</li>\n" );
807 $wgDatabase->ignoreErrors( true );
808 $myver = $wgDatabase->getServerVersion();
810 # There were errors, report them and back out
812 $errno = mysql_errno();
813 $errtx = htmlspecialchars( mysql_error() );
817 echo( "failed due to authentication errors. Check passwords.</li>" );
819 # The superuser details are wrong
820 $errs["RootUser"] = "Check username";
821 $errs["RootPW"] = "and password";
823 # The regular user details are wrong
824 $errs["DBuser"] = "Check username";
825 $errs["DBpassword"] = "and password";
831 # General connection problem
832 echo( "failed with error [$errno] $errtx.</li>\n" );
833 $errs["DBserver"] = "Connection failed";
838 if( !$ok ) { continue; }
841 error_reporting( E_ALL
);
843 ## Possible connect as a superuser
844 if( $useRoot && $conf->DBtype
!= 'sqlite' ) {
845 $wgDBsuperuser = $conf->RootUser
;
846 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
847 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
848 if (!$wgDatabase->isOpen()) {
849 print " error: " . $wgDatabase->lastError() . "</li>\n";
850 $errs["DBserver"] = "Could not connect to database as superuser";
851 $errs["RootUser"] = "Check username";
852 $errs["RootPW"] = "and password";
855 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
857 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
858 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
859 if (!$wgDatabase->isOpen()) {
860 print " error: " . $wgDatabase->lastError() . "</li>\n";
862 $myver = $wgDatabase->getServerVersion();
864 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
867 if ( !$wgDatabase->isOpen() ) {
868 $errs["DBserver"] = "Couldn't connect to database";
872 print "<li>Connected to $myver";
873 if ($conf->DBtype
== 'mysql') {
874 if( version_compare( $myver, "4.0.14" ) < 0 ) {
875 dieout( " -- mysql 4.0.14 or later required. Aborting." );
877 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
878 if( $mysqlNewAuth && $mysqlOldClient ) {
879 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
880 to old client libraries; if you have trouble with authentication, see
881 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
882 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
885 if( $mysqlNewAuth ) {
886 print "; enabling MySQL 4.1/5.0 charset mode";
888 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
889 but older version detected; will likely fail.</b>";
894 @$sel = $wgDatabase->selectDB( $wgDBname );
896 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
898 $err = mysql_errno();
899 $databaseSafe = htmlspecialchars( $wgDBname );
900 if( $err == 1102 /* Invalid database name */ ) {
901 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
903 } elseif( $err != 1049 /* Database doesn't exist */ ) {
904 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
905 print htmlspecialchars( mysql_error() ) . "</li></ul>";
908 print "<li>Attempting to create database...</li>";
909 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
911 print "<li>Couldn't create database <tt>" .
912 htmlspecialchars( $wgDBname ) .
913 "</tt>; try with root access or check your username/pass.</li>\n";
914 $errs["RootPW"] = "<- Enter";
917 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
919 $wgDatabase->selectDB( $wgDBname );
921 else if ($conf->DBtype
== 'postgres') {
922 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
923 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
927 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
928 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
930 if ( $conf->DBtype
== 'mysql') {
931 # Determine existing default character set
932 if ( $wgDatabase->tableExists( "revision" ) ) {
933 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
934 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
935 $row = $wgDatabase->fetchObject( $res );
937 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
938 $existingSchema = false;
939 $existingEngine = false;
941 if ( preg_match( '/^latin1/', $row->Collation
) ) {
942 $existingSchema = 'mysql4';
943 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
944 $existingSchema = 'mysql5';
945 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
946 $existingSchema = 'mysql5-binary';
948 $existingSchema = false;
949 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
951 if ( isset( $row->Engine
) ) {
952 $existingEngine = $row->Engine
;
954 $existingEngine = $row->Type
;
957 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
958 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
959 "but the existing database has the $existingSchema schema. This upgrade script ".
960 "can't convert it, so it will remain $existingSchema.</li>\n";
961 $conf->setSchema( $existingSchema, $conf->DBengine
);
963 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
964 print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
965 "engine, but the existing database uses the $existingEngine engine. This upgrade " .
966 "script can't convert it, so it will remain $existingEngine.</li>\n";
967 $conf->setSchema( $conf->DBschema
, $existingEngine );
971 # Create user if required
973 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
974 if ( $conn->isOpen() ) {
975 print "<li>DB user account ok</li>\n";
978 print "<li>Granting user permissions...";
979 if( $mysqlOldClient && $mysqlNewAuth ) {
980 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>";
983 dbsource( "../maintenance/users.sql", $wgDatabase );
987 print "</ul><pre>\n";
993 print "<ul><li>Finished update checks.</li>\n";
995 # Determine available storage engines if possible
996 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
997 $res = $wgDatabase->query( 'SHOW ENGINES' );
999 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1000 if ( $row->Engine
== $conf->DBengine
) {
1005 $wgDatabase->freeResult( $res );
1006 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1007 echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
1008 "using MyISAM instead</li>\n";
1009 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1013 # FIXME: Check for errors
1014 print "<li>Creating tables...";
1015 if ($conf->DBtype
== 'mysql') {
1016 dbsource( "../maintenance/tables.sql", $wgDatabase );
1017 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1018 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1019 $wgDatabase->setup_database();
1022 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1026 print " done.</li>\n";
1028 print "<li>Initializing statistics...</li>\n";
1029 $wgDatabase->insert( 'site_stats',
1030 array ( 'ss_row_id' => 1,
1031 'ss_total_views' => 0,
1032 'ss_total_edits' => 1, # Main page first edit
1033 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1034 'ss_total_pages' => 1, # Main page
1035 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1036 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1037 'ss_images' => 0 ) );
1039 # Set up the "regular user" account *if we can, and if we need to*
1040 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1042 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1043 if( $wgDatabase2->isOpen() ) {
1044 # Nope, just close the test connection and continue
1045 $wgDatabase2->close();
1046 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
1048 # Yes, so run the grants
1049 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
1050 dbsource( "../maintenance/users.sql", $wgDatabase );
1051 echo( "success.</li>\n" );
1055 if( $conf->SysopName
) {
1056 $u = User
::newFromName( $conf->getSysopName() );
1058 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1060 else if ( 0 == $u->idForName() ) {
1061 $u->addToDatabase();
1062 $u->setPassword( $conf->getSysopPass() );
1065 $u->addGroup( "sysop" );
1066 $u->addGroup( "bureaucrat" );
1068 print "<li>Created sysop account <tt>" .
1069 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1071 print "<li>Could not create user - already exists!</li>\n";
1074 print "<li>Skipped sysop account creation, no name given.</li>\n";
1077 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1078 $article = new Article( $titleobj );
1079 $newid = $article->insertOn( $wgDatabase );
1080 $revision = new Revision( array(
1082 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1085 'user_text' => 'MediaWiki default',
1087 $revid = $revision->insertOn( $wgDatabase );
1088 $article->updateRevisionOn( $wgDatabase, $revision );
1091 /* Write out the config file now that all is well */
1092 print "<li style=\"list-style: none\">\n";
1093 print "<p>Creating LocalSettings.php...</p>\n\n";
1094 $localSettings = "<" . "?php$endl$local";
1095 // Fix up a common line-ending problem (due to CVS on Windows)
1096 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1097 $f = fopen( "LocalSettings.php", 'xt' );
1100 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" .
1101 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1102 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1104 if(fwrite( $f, $localSettings ) ) {
1106 print "</li></ul><hr/>\n";
1107 writeSuccessMessage();
1110 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");
1111 print "</li></ul>\n";
1122 if( count( $errs ) ) {
1123 /* Display options form */
1125 if( $conf->posted
) {
1126 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1130 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1133 <h2
>Site config
</h2
>
1135 <div
class="config-section">
1136 <div
class="config-input">
1138 aField( $conf, "Sitename", "Wiki name:" );
1141 <p
class="config-desc">
1142 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1143 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1146 <div
class="config-input">
1148 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1151 <p
class="config-desc">
1152 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
.
1155 <div
class="config-input">
1156 <label
class='column' for="LanguageCode">Language
:</label
>
1157 <select id
="LanguageCode" name
="LanguageCode">
1160 $list = getLanguageList();
1161 foreach( $list as $code => $name ) {
1162 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1163 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1168 <p
class="config-desc">
1169 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1172 <div
class="config-input">
1173 <label
class='column'>Copyright
/license
:</label
>
1176 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1177 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1179 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1180 $partner = "MediaWiki";
1181 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1182 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1183 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1184 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1185 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1187 <?php
if( $conf->License
== "cc" ) { ?
>
1189 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1190 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1191 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1192 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1198 <p
class="config-desc">
1199 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1203 <div
class="config-input">
1204 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1206 <div
class="config-input">
1207 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1209 <div
class="config-input">
1210 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1212 <p
class="config-desc">
1213 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1214 A
new account will be added only when creating a
new wiki database
.
1216 The password cannot be the same
as the username
.
1219 <div
class="config-input">
1220 <label
class='column'>Object caching
:</label
>
1223 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1225 if ( $conf->turck
) {
1227 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1230 if( $conf->xcache
) {
1232 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1237 aField( $conf, "Shm", "APC", "radio", "apc" );
1240 if ( $conf->eaccel
) {
1242 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1247 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1251 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1253 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1255 <p
class="config-desc">
1256 An
object caching system such
as memcached will provide a significant performance boost
,
1257 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1259 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1260 these should not be used
if the wiki will be running on multiple application servers
.
1262 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1263 recommended
for testing
.
1267 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1269 <div
class="config-section">
1270 <div
class="config-input">
1271 <label
class='column'>E
-mail
features (global):</label
>
1273 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1274 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1277 <p
class="config-desc">
1278 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1279 if sending mail doesn
't work on your server.
1282 <div class="config-input">
1283 <label class='column
'>User-to-user e-mail:</label>
1285 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1286 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1289 <p class="config-desc">
1290 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.
1292 <div class="config-input">
1293 <label class='column
'>E-mail notification about changes:</label>
1295 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1296 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1297 <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>
1300 <div class="config-desc">
1302 For this feature to work, an e-mail address must be present for the user account, and the notification
1303 options in the user's preferences must be enabled
. Also note the
1304 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1306 <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
>
1309 <div
class="config-input">
1310 <label
class='column'>E
-mail address authentication
:</label
>
1312 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1313 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1316 <div
class="config-desc">
1317 <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
1318 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1323 <h2
>Database config
</h2
>
1325 <div
class="config-section">
1326 <div
class="config-input">
1327 <label
class='column'>Database type
:</label
>
1328 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1329 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1332 <div
class="config-input" style
="clear:left"><?php
1333 aField( $conf, "DBserver", "Database host:" );
1335 <p
class="config-desc">
1336 If your database server isn
't on your web server, enter the name or IP address here.
1339 <div class="config-input"><?php
1340 aField( $conf, "DBname", "Database name:" );
1342 <div class="config-input"><?php
1343 aField( $conf, "DBuser", "DB username:" );
1345 <div class="config-input"><?php
1346 aField( $conf, "DBpassword", "DB password:", "password" );
1348 <div class="config-input"><?php
1349 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1351 <p class="config-desc">
1352 If you only have a single user account and database available,
1353 enter those here. If you have database root access (see below)
1354 you can specify new accounts/databases to be created. This account
1355 will not be created if it pre-exists. If this is the case, ensure that it
1356 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1359 <div class="config-input">
1360 <label class="column">Superuser account:</label>
1361 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1362 <label for="useroot">Use superuser account</label>
1364 <div class="config-input">
1366 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1369 <div class="config-input">
1371 aField( $conf, "RootPW", "Superuser password:", "password" );
1375 <p class="config-desc">
1376 If the database user specified above does not exist, or does not have access to create
1377 the database (if needed) or tables within it, please check the box and provide details
1378 of a superuser account, such as <strong>root</strong>, which does.
1381 <?php database_switcher('mysql
'); ?>
1382 <div class="config-input"><?php
1383 aField( $conf, "DBprefix", "Database table prefix:" );
1385 <div class="config-desc">
1386 <p>If you need to share one database between multiple wikis, or
1387 between MediaWiki and another web application, you may choose to
1388 add a prefix to all the table names to avoid conflicts.</p>
1390 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1393 <div class="config-input"><label class="column">Storage Engine</label>
1394 <div>Select one:</div>
1396 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1397 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1400 <p class="config-desc">
1401 InnoDB is best for public web installations, since it has good concurrency
1402 support. MyISAM may be faster in single-user installations. MyISAM databases
1403 tend to get corrupted more often than InnoDB databases.
1405 <div class="config-input"><label class="column">Database character set</label>
1406 <div>Select one:</div>
1408 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1409 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1410 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1413 <p class="config-desc">
1414 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1415 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1416 cause things to break. <b>If upgrading an older installation, leave
1417 in backwards-compatible mode.</b>
1421 <?php database_switcher('postgres
'); ?>
1422 <div class="config-input"><?php
1423 aField( $conf, "DBport", "Database port:" );
1425 <div class="config-input"><?php
1426 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1428 <div class="config-input"><?php
1429 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1431 <div class="config-desc">
1432 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1433 so it is recommended that you create a new user. The above schemas are generally correct:
1434 only change them if you are sure you need to.</p>
1438 <?php database_switcher('sqlite
'); ?>
1439 <div class="config-input"><?php
1440 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1442 <div class="config-desc">
1443 <p>SQLite stores table data into files in the filesystem.
1444 If you do not provide an explicit path, a "data" directory in
1445 the parent of your document root will be used.</p>
1447 <p>This directory must exist and be writable by the web server.</p>
1451 <div class="config-input" style="padding:2em 0 3em">
1452 <label class='column
'> </label>
1453 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1458 <script type="text/javascript">
1459 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1461 ## If they passed in a root user name, don't populate it on page load
1462 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1471 /* -------------------------------------------------------------------------------------- */
1472 function writeSuccessMessage() {
1473 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1474 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1476 <div class="success-box">
1477 <p>Installation successful!</p>
1478 <p>To complete the installation, please do the following:
1480 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1481 <li>Upload it to the parent directory</li>
1482 <li>Delete config/LocalSettings.php</li>
1483 <li>Start using <a href='../$script'>your wiki</a>!
1485 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1486 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1487 which means that anyone on the same server can read your database password! Downloading
1488 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1493 <div class="success-box">
1495 <span class="success-message">Installation successful!</span>
1496 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1497 <a href="../$script"> this link</a> to your wiki.</p>
1498 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1499 prevent other users on the server reading passwords and altering configuration data.</p>
1506 function escapePhpString( $string ) {
1507 if ( is_array( $string ) ||
is_object( $string ) ) {
1510 return strtr( $string,
1521 function writeLocalSettings( $conf ) {
1522 $conf->PasswordSender
= $conf->EmergencyContact
;
1523 $magic = ($conf->ImageMagick ?
"" : "# ");
1524 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1525 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1526 $hashedUploads = $conf->safeMode ?
'' : '# ';
1528 switch ( $conf->Shm
) {
1530 $cacheType = 'CACHE_MEMCACHED';
1531 $mcservers = var_export( $conf->MCServerArray
, true );
1537 $cacheType = 'CACHE_ACCEL';
1538 $mcservers = 'array()';
1541 $cacheType = 'CACHE_DBA';
1542 $mcservers = 'array()';
1545 $cacheType = 'CACHE_NONE';
1546 $mcservers = 'array()';
1549 if ( $conf->Email
== 'email_enabled' ) {
1550 $enableemail = 'true';
1551 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1552 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1553 switch ( $conf->Enotif
) {
1554 case 'enotif_usertalk':
1555 $enotifusertalk = 'true';
1556 $enotifwatchlist = 'false';
1558 case 'enotif_allpages':
1559 $enotifusertalk = 'true';
1560 $enotifwatchlist = 'true';
1563 $enotifusertalk = 'false';
1564 $enotifwatchlist = 'false';
1567 $enableuseremail = 'false';
1568 $enableemail = 'false';
1569 $eauthent = 'false';
1570 $enotifusertalk = 'false';
1571 $enotifwatchlist = 'false';
1574 $file = @fopen
( "/dev/urandom", "r" );
1576 $secretKey = bin2hex( fread( $file, 32 ) );
1580 for ( $i=0; $i<8; $i++
) {
1581 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1583 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1586 # Add slashes to strings for double quoting
1587 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1588 if( $conf->License
== 'gfdl' ) {
1589 # Needs literal string interpolation for the current style path
1590 $slconf['RightsIcon'] = $conf->RightsIcon
;
1593 if( $conf->DBtype
== 'mysql' ) {
1595 "# MySQL specific settings
1596 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1598 # MySQL table options to use during installation or update
1599 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1601 # Experimental charset support for MySQL 4.1/5.0.
1602 \$wgDBmysql5 = {$conf->DBmysql5};";
1603 } elseif( $conf->DBtype
== 'postgres' ) {
1605 "# Postgres specific settings
1606 \$wgDBport = \"{$slconf['DBport']}\";
1607 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1608 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1609 } elseif( $conf->DBtype
== 'sqlite' ) {
1611 "# SQLite-specific settings
1612 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1620 # This file was automatically generated by the MediaWiki installer.
1621 # If you make manual changes, please keep track in case you need to
1622 # recreate them later.
1624 # See includes/DefaultSettings.php for all configurable settings
1625 # and their default values, but don't forget to make changes in _this_
1628 # Further documentation for configuration settings may be found at:
1629 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1631 # If you customize your file layout, set \$IP to the directory that contains
1632 # the other MediaWiki files. It will be used as a base to locate files.
1633 if( defined( 'MW_INSTALL_PATH' ) ) {
1634 \$IP = MW_INSTALL_PATH;
1636 \$IP = dirname( __FILE__ );
1639 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1640 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1642 require_once( \"\$IP/includes/DefaultSettings.php\" );
1644 # If PHP's memory limit is very low, some operations may fail.
1645 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1647 if ( \$wgCommandLineMode ) {
1648 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1649 die( \"This script must be run from the command line\\n\" );
1652 ## Uncomment this to disable output compression
1653 # \$wgDisableOutputCompression = true;
1655 \$wgSitename = \"{$slconf['Sitename']}\";
1657 ## The URL base path to the directory containing the wiki;
1658 ## defaults for all runtime URL paths are based off of this.
1659 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1660 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1662 ## For more information on customizing the URLs please see:
1663 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1665 \$wgEnableEmail = $enableemail;
1666 \$wgEnableUserEmail = $enableuseremail;
1668 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1669 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1671 ## UPO means: this is also a user preference option
1672 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1673 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1674 \$wgEmailAuthentication = $eauthent;
1676 \$wgDBtype = \"{$slconf['DBtype']}\";
1677 \$wgDBserver = \"{$slconf['DBserver']}\";
1678 \$wgDBname = \"{$slconf['DBname']}\";
1679 \$wgDBuser = \"{$slconf['DBuser']}\";
1680 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1684 ## Shared memory settings
1685 \$wgMainCacheType = $cacheType;
1686 \$wgMemCachedServers = $mcservers;
1688 ## To enable image uploads, make sure the 'images' directory
1689 ## is writable, then set this to true:
1690 \$wgEnableUploads = false;
1691 {$magic}\$wgUseImageMagick = true;
1692 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1694 ## If you want to use image uploads under safe mode,
1695 ## create the directories images/archive, images/thumb and
1696 ## images/temp, and make them all writable. Then uncomment
1697 ## this, if it's not already uncommented:
1698 {$hashedUploads}\$wgHashedUploadDirectory = false;
1700 ## If you have the appropriate support software installed
1701 ## you can enable inline LaTeX equations:
1704 \$wgLocalInterwiki = \$wgSitename;
1706 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1708 \$wgProxyKey = \"$secretKey\";
1710 ## Default skin: you can change the default skin. Use the internal symbolic
1711 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1712 \$wgDefaultSkin = 'monobook';
1714 ## For attaching licensing metadata to pages, and displaying an
1715 ## appropriate copyright notice / icon. GNU Free Documentation
1716 ## License and Creative Commons licenses are supported so far.
1717 {$rights}\$wgEnableCreativeCommonsRdf = true;
1718 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1719 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1720 \$wgRightsText = \"{$slconf['RightsText']}\";
1721 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1722 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1724 \$wgDiff3 = \"{$slconf['diff3']}\";
1726 # When you make changes to this configuration file, this will make
1727 # sure that cached pages are cleared.
1728 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1729 "; ## End of setting the $localsettings string
1731 // Keep things in Unix line endings internally;
1732 // the system will write out as local text type.
1733 return str_replace( "\r\n", "\n", $localsettings );
1736 function dieout( $text ) {
1737 die( $text . "\n\n</body>\n</html>" );
1740 function importVar( &$var, $name, $default = "" ) {
1741 if( isset( $var[$name] ) ) {
1742 $retval = $var[$name];
1743 if ( get_magic_quotes_gpc() ) {
1744 $retval = stripslashes( $retval );
1752 function importPost( $name, $default = "" ) {
1753 return importVar( $_POST, $name, $default );
1756 function importCheck( $name ) {
1757 return isset( $_POST[$name] );
1760 function importRequest( $name, $default = "" ) {
1761 return importVar( $_REQUEST, $name, $default );
1766 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1769 $xtype = "type=\"$type\"";
1775 $nolabel = ($type == "radio") ||
($type == "hidden");
1777 if ($type == 'radio')
1778 $id .= $radioCount++
;
1783 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1786 if( $type == "radio" && $value == $conf->$field ) {
1787 $checked = "checked='checked'";
1791 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1793 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1796 if( $type == "radio" ) {
1797 echo htmlspecialchars( $value );
1799 echo htmlspecialchars( $conf->$field );
1805 echo " $text</label>\n";
1809 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1812 function getLanguageList() {
1813 global $wgLanguageNames, $IP;
1814 if( !isset( $wgLanguageNames ) ) {
1815 require_once( "$IP/languages/Names.php" );
1820 $d = opendir( "../languages/messages" );
1821 /* In case we are called from the root directory */
1823 $d = opendir( "languages/messages");
1824 while( false !== ($f = readdir( $d ) ) ) {
1826 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1827 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1828 if( isset( $wgLanguageNames[$code] ) ) {
1829 $name = $code . ' - ' . $wgLanguageNames[$code];
1833 $codes[$code] = $name;
1841 #Check for location of an executable
1842 # @param string $loc single location to check
1843 # @param array $names filenames to check for.
1844 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1845 function locate_executable($loc, $names, $versioninfo = false) {
1846 if (!is_array($names))
1847 $names = array($names);
1849 foreach ($names as $name) {
1850 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1851 if (@file_exists
($command)) {
1855 $file = str_replace('$1', $command, $versioninfo[0]);
1856 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1863 # Test a memcached server
1864 function testMemcachedServer( $server ) {
1865 $hostport = explode(":", $server);
1868 if ( !function_exists( 'fsockopen' ) ) {
1869 $errstr = "Can't connect to memcached, fsockopen() not present";
1871 if ( !$errstr && count( $hostport ) != 2 ) {
1872 $errstr = 'Please specify host and port';
1875 list( $host, $port ) = $hostport;
1879 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1880 if ( $fp === false ) {
1881 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1885 $command = "version\r\n";
1886 $bytes = fwrite( $fp, $command );
1887 if ( $bytes != strlen( $command ) ) {
1888 $errstr = "Cannot write to memcached socket on $host:$port";
1892 $expected = "VERSION ";
1893 $response = fread( $fp, strlen( $expected ) );
1894 if ( $response != $expected ) {
1895 $errstr = "Didn't get correct memcached response from $host:$port";
1902 echo "<li>Connected to memcached on $host:$port successfully";
1907 function database_picker($conf) {
1910 foreach(array_keys($ourdb) as $db) {
1911 if ($ourdb[$db]['havedriver']) {
1913 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1920 function database_switcher($db) {
1922 $color = $ourdb[$db]['bgcolor'];
1923 $full = $ourdb[$db]['fullname'];
1924 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
1927 function printListItem( $item ) {
1928 print "<li>$item</li>";
1933 <div
class="license">
1935 <p
>This program is free software
; you can redistribute it
and/or modify
1936 it under the terms of the GNU General
Public License
as published by
1937 the Free Software Foundation
; either version
2 of the License
, or
1938 (at your option
) any later version
.</p
>
1940 <p
>This program is distributed in the hope that it will be useful
,
1941 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1942 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1943 GNU General
Public License
for more details
.</p
>
1945 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1946 along with this program
; if not
, write to the Free Software
1947 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1948 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1954 <div id
="column-one">
1955 <div
class="portlet" id
="p-logo">
1956 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1957 href
="http://www.mediawiki.org/"
1958 title
="Main Page"></a
>
1960 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1961 <div
class='portlet'><div
class='pBody'>
1963 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1964 <li
><a href
="../README">Readme
</a
></li
>
1965 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1966 <li
><a href
="../docs/">Documentation
</a
></li
>
1967 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1968 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
1970 <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>