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 );
32 $sep = PATH_SEPARATOR
;
33 if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
34 set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
37 # Define an entry point and include some files
38 define( "MEDIAWIKI", true );
39 define( "MEDIAWIKI_INSTALL", true );
41 // Run version checks before including other files
42 // so people don't see a scary parse error.
43 require_once( "install-utils.inc" );
44 install_version_checks();
46 require_once( "includes/Defines.php" );
47 require_once( "includes/DefaultSettings.php" );
48 require_once( "includes/AutoLoader.php" );
49 require_once( "includes/MagicWord.php" );
50 require_once( "includes/Namespace.php" );
51 require_once( "includes/ProfilerStub.php" );
52 require_once( "includes/GlobalFunctions.php" );
53 require_once( "includes/Hooks.php" );
55 # If we get an exception, the user needs to know
57 $wgShowExceptionDetails = true;
59 ## Databases we support:
62 $ourdb['mysql']['fullname'] = 'MySQL';
63 $ourdb['mysql']['havedriver'] = 0;
64 $ourdb['mysql']['compile'] = 'mysql';
65 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
66 $ourdb['mysql']['rootuser'] = 'root';
68 $ourdb['postgres']['fullname'] = 'PostgreSQL';
69 $ourdb['postgres']['havedriver'] = 0;
70 $ourdb['postgres']['compile'] = 'pgsql';
71 $ourdb['postgres']['bgcolor'] = '#aaccff';
72 $ourdb['postgres']['rootuser'] = 'postgres';
75 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
78 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
79 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
80 <style type
="text/css">
82 @import
"../skins/monobook/main.css";
86 margin
: 1em
0 1em
2.5em
;
93 .config
-section label
.column
{
105 zoom
: 100%
; /* IE hack */
108 .config
-section
.config
-desc
{
110 margin
: 0 0 2em
18em
;
115 .iput
-text
, .iput
-password
{
122 background
-color
: #fff;
130 background
-color
: #FFF0F0;
131 border
: 2px solid red
;
139 list-style
-type
: none
;
140 list-style
-image
: none
;
158 <script type
="text/javascript">
161 <?php
foreach (array_keys($ourdb) as $db) {
162 echo "\n document.getElementById('$db').style.display='none';";
167 function toggleDBarea(id
,defaultroot
) {
169 var dbarea
= document
.getElementById(id
).style
;
170 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
171 var db
= document
.getElementById('RootUser');
173 <?php
foreach (array_keys($ourdb) as $db) {
174 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
183 <div id
="globalWrapper">
184 <div id
="column-content">
186 <div id
="bodyContent">
188 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
192 /* Check for existing configurations and bug out! */
194 if( file_exists( "../LocalSettings.php" ) ) {
195 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
197 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
200 if( file_exists( "./LocalSettings.php" ) ) {
201 writeSuccessMessage();
206 if( !is_writable( "." ) ) {
207 dieout( "<h2>Can't write config file, aborting</h2>
209 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
210 writable by the web server. Once configuration is done you'll move the created
211 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
212 then remove the <tt>config</tt> subdirectory entirely.</p>
214 <p>To make the directory writable on a Unix/Linux system:</p>
217 cd <i>/path/to/wiki</i>
221 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
225 require_once( "install-utils.inc" );
226 require_once( "maintenance/updaters.inc" );
229 function getEncoded( $data ) {
230 # removing latin1 support, no need...
233 function getSitename() { return $this->getEncoded( $this->Sitename
); }
234 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
235 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
237 function setSchema( $schema ) {
238 $this->DBschema
= $schema;
239 switch ( $this->DBschema
) {
241 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
242 $this->DBmysql5
= 'true';
244 case 'mysql5-binary':
245 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
246 $this->DBmysql5
= 'true';
249 $this->DBTableOptions
= 'TYPE=InnoDB';
250 $this->DBmysql5
= 'false';
252 # Set the global for use during install
253 global $wgDBTableOptions;
254 $wgDBTableOptions = $this->DBTableOptions
;
262 <b
>Don
't forget security updates!</b> Keep an eye on the
263 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
264 release announcements mailing list</a>.
269 <h2>Checking environment...</h2>
270 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
271 <ul class="env-check">
275 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
276 $conf = new ConfigData;
278 install_version_checks();
279 $self = 'Installer
'; # Maintenance script name, to please Setup.php
281 print "<li>PHP " . phpversion() . " installed</li>\n";
283 error_reporting( 0 );
284 $phpdatabases = array();
285 foreach (array_keys($ourdb) as $db) {
286 $compname = $ourdb[$db]['compile
'];
287 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
288 array_push($phpdatabases, $db);
289 $ourdb[$db]['havedriver
'] = 1;
292 error_reporting( E_ALL );
294 if (!$phpdatabases) {
295 print "Could not find a suitable database driver!<ul>";
296 foreach (array_keys($ourdb) AS $db) {
297 $comp = $ourdb[$db]['compile
'];
298 $full = $ourdb[$db]['fullname
'];
299 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
300 ."or install the $comp.so module</li>\n";
302 dieout( "</ul></ul>" );
305 print "<li>Found database drivers for:";
306 foreach (array_keys($ourdb) AS $db) {
307 if ($ourdb[$db]['havedriver
']) {
308 $DefaultDBtype = $db;
309 print " ".$ourdb[$db]['fullname
'];
313 if (count($phpdatabases) != 1)
316 if( ini_get( "register_globals" ) ) {
319 <div style="font-size:110%">
320 <strong class="error">Warning:</strong>
321 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
323 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
330 if( ini_get( "magic_quotes_runtime" ) ) {
332 ?
><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
>
333 This option corrupts data input unpredictably
; you cannot install
or use
334 MediaWiki unless this option is disabled
.
338 if( ini_get( "magic_quotes_sybase" ) ) {
340 ?
><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
>
341 This option corrupts data input unpredictably
; you cannot install
or use
342 MediaWiki unless this option is disabled
.
346 if( ini_get( "mbstring.func_overload" ) ) {
348 ?
><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
>
349 This option causes errors
and may corrupt data unpredictably
;
350 you cannot install
or use MediaWiki unless this option is disabled
.
354 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
356 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
357 This option causes horrible bugs with MediaWiki
; you cannot install
or use
358 MediaWiki unless this option is disabled
.
364 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
367 if( ini_get( "safe_mode" ) ) {
368 $conf->safeMode
= true;
370 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
371 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
372 You may have problems caused by this
, particularly
if using image uploads
.
376 $conf->safeMode
= false;
379 $sapi = php_sapi_name();
380 print "<li>PHP server API is $sapi; ";
381 if( $wgUsePathInfo ) {
382 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
384 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
388 $conf->xml
= function_exists( "utf8_encode" );
390 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
392 dieout( "PHP's XML module is missing; the wiki requires functions in
393 this module and won't work in this configuration.
394 If you're running Mandrake, install the php-xml package." );
397 # Check for session support
398 if( !function_exists( 'session_name' ) )
399 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
401 # session.save_path doesn't *have* to be set, but if it is, and it's
402 # not valid/writable/etc. then it can cause problems
403 $sessionSavePath = mw_get_session_save_path();
404 $ssp = htmlspecialchars( $sessionSavePath );
405 # Warn the user if it's not set, but let them proceed
406 if( !$sessionSavePath ) {
407 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
408 has not been set in PHP.ini. If the default value causes problems with
409 saving session data, set it to a valid path which is read/write/execute
410 for the user your web server is running under.</li>";
411 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
412 # All good? Let the user know
413 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
415 # Something not right? Warn the user, but let them proceed
416 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
417 appears to be invalid or is not writable. PHP needs to be able to save data to
418 this location for correct session operation.</li>";
421 # Check for PCRE support
422 if( !function_exists( 'preg_match' ) )
423 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
424 Perl-compatible regular expression functions." );
426 $memlimit = ini_get( "memory_limit" );
427 $conf->raiseMemory
= false;
428 if( empty( $memlimit ) ||
$memlimit == -1 ) {
429 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
431 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
432 $n = intval( $memlimit );
433 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
434 $n = intval( $m[1] * (1024*1024) );
436 if( $n < 20*1024*1024 ) {
437 print "Attempting to raise limit to 20M... ";
438 if( false === ini_set( "memory_limit", "20M" ) ) {
439 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
441 $conf->raiseMemory
= true;
448 $conf->turck
= function_exists( 'mmcache_get' );
449 if ( $conf->turck
) {
450 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
453 $conf->xcache
= function_exists( 'xcache_get' );
455 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
457 $conf->apc
= function_exists('apc_fetch');
459 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
462 $conf->eaccel
= function_exists( 'eaccelerator_get' );
463 if ( $conf->eaccel
) {
464 $conf->turck
= 'eaccelerator';
465 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
468 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
469 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
470 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
471 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>.
472 Object caching functions cannot be used.</li>' );
475 $conf->diff3
= false;
476 $diff3locations = array_merge(
483 explode( $sep, getenv( "PATH" ) ) );
484 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
486 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
487 foreach ($diff3locations as $loc) {
488 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
489 if ($exe !== false) {
496 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
498 print "<li>GNU diff3 not found.</li>";
500 $conf->ImageMagick
= false;
501 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
502 foreach( $imcheck as $dir ) {
503 $im = "$dir/convert";
504 if( file_exists( $im ) ) {
505 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
506 $conf->ImageMagick
= $im;
511 $conf->HaveGD
= function_exists( "imagejpeg" );
512 if( $conf->HaveGD
) {
513 print "<li>Found GD graphics library built-in";
514 if( !$conf->ImageMagick
) {
515 print ", image thumbnailing will be enabled if you enable uploads";
519 if( !$conf->ImageMagick
) {
520 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
524 $conf->IP
= dirname( dirname( __FILE__
) );
525 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
528 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
529 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
530 // to get the path to the current script... hopefully it's reliable. SIGH
531 $path = ($_SERVER["PHP_SELF"] === '')
532 ?
$_SERVER["SCRIPT_NAME"]
533 : $_SERVER["PHP_SELF"];
534 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
535 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
537 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
538 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
540 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
541 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
543 : $_SERVER["SERVER_ADMIN"];
544 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
545 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
549 $conf->DBserver
= importPost( "DBserver", "localhost" );
550 $conf->DBname
= importPost( "DBname", "wikidb" );
551 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
552 $conf->DBpassword
= importPost( "DBpassword" );
553 $conf->DBpassword2
= importPost( "DBpassword2" );
554 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
555 $conf->SysopPass
= importPost( "SysopPass" );
556 $conf->SysopPass2
= importPost( "SysopPass2" );
557 $conf->RootUser
= importPost( "RootUser", "root" );
558 $conf->RootPW
= importPost( "RootPW", "" );
559 $useRoot = importCheck( 'useroot', false );
560 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
563 $conf->DBprefix
= importPost( "DBprefix" );
564 $conf->setSchema( importPost( "DBschema", "mysql4" ) );
566 ## Postgres specific:
567 $conf->DBport
= importPost( "DBport", "5432" );
568 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
569 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
571 /* Check for validity */
574 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
575 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
577 if( $conf->DBuser
== "" ) {
578 $errs["DBuser"] = "Must not be blank";
580 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
581 $errs["DBuser"] = "Username too long";
583 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
584 $errs["DBpassword"] = "Must not be blank";
586 if( $conf->DBpassword
!= $conf->DBpassword2
) {
587 $errs["DBpassword2"] = "Passwords don't match!";
589 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
590 $errs["DBprefix"] = "Invalid table prefix";
593 error_reporting( E_ALL
);
596 * Initialise $wgLang and $wgContLang to something so we can
597 * call case-folding methods. Per Brion, this is English for
598 * now, although we could be clever and initialise to the
599 * user-selected language.
601 $wgContLang = Language
::factory( 'en' );
602 $wgLang = $wgContLang;
605 * We're messing about with users, so we need a stub
606 * authentication plugin...
608 $wgAuth = new AuthPlugin();
611 * Validate the initial administrator account; username,
612 * password checks, etc.
614 if( $conf->SysopName
) {
615 # Check that the user can be created
616 $u = User
::newFromName( $conf->SysopName
);
617 if( $u instanceof User
) {
618 # Various password checks
619 if( $conf->SysopPass
!= '' ) {
620 if( $conf->SysopPass
== $conf->SysopPass2
) {
621 if( !$u->isValidPassword( $conf->SysopPass
) ) {
622 $errs['SysopPass'] = "Bad password";
625 $errs['SysopPass2'] = "Passwords don't match";
628 $errs['SysopPass'] = "Cannot be blank";
632 $errs['SysopName'] = "Bad username";
636 $conf->License
= importRequest( "License", "none" );
637 if( $conf->License
== "gfdl" ) {
638 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
639 $conf->RightsText
= "GNU Free Documentation License 1.2";
640 $conf->RightsCode
= "gfdl";
641 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
642 } elseif( $conf->License
== "none" ) {
643 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
645 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
646 $conf->RightsText
= importRequest( "RightsText", "" );
647 $conf->RightsCode
= importRequest( "RightsCode", "" );
648 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
651 $conf->Shm
= importRequest( "Shm", "none" );
652 $conf->MCServers
= importRequest( "MCServers" );
654 /* Test memcached servers */
656 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
657 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
658 foreach ( $conf->MCServerArray
as $server ) {
659 $error = testMemcachedServer( $server );
661 $errs["MCServers"] = $error;
665 } else if ( $conf->Shm
== 'memcached' ) {
666 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
669 /* default values for installation */
670 $conf->Email
= importRequest("Email", "email_enabled");
671 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
672 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
673 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
675 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
676 do { /* So we can 'continue' to end prematurely */
677 $conf->Root
= ($conf->RootPW
!= "");
679 /* Load up the settings and get installin' */
680 $local = writeLocalSettings( $conf );
681 echo "<li style=\"list-style: none\">\n";
682 echo "<p><b>Generating configuration file...</b></p>\n";
685 $wgCommandLineMode = false;
687 $ok = eval( $local );
688 if( $ok === false ) {
689 dieout( "Errors in generated configuration; " .
690 "most likely due to a bug in the installer... " .
691 "Config file was: " .
693 htmlspecialchars( $local ) .
697 $conf->DBtypename
= '';
698 foreach (array_keys($ourdb) as $db) {
699 if ($conf->DBtype
=== $db)
700 $conf->DBtypename
= $ourdb[$db]['fullname'];
702 if ( ! strlen($conf->DBtype
)) {
703 $errs["DBpicktype"] = "Please choose a database type";
707 if (! $conf->DBtypename
) {
708 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
711 print "<li>Database type: {$conf->DBtypename}</li>\n";
712 $dbclass = 'Database'.ucfirst($conf->DBtype
);
713 $wgDBtype = $conf->DBtype
;
714 $wgDBadminuser = "root";
715 $wgDBadminpassword = $conf->RootPW
;
718 $wgDBprefix = $conf->DBprefix
;
720 ## Postgres specific:
721 $wgDBport = $conf->DBport
;
722 $wgDBmwschema = $conf->DBmwschema
;
723 $wgDBts2schema = $conf->DBts2schema
;
725 $wgCommandLineMode = true;
726 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
727 require_once( "includes/Setup.php" );
730 $wgTitle = Title
::newFromText( "Installation script" );
731 error_reporting( E_ALL
);
732 print "<li>Loading class: $dbclass";
735 if( $conf->DBtype
== 'mysql' ) {
736 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
737 if( $mysqlOldClient ) {
738 print "<li><b>PHP is linked with old MySQL client libraries. If you are
739 using a MySQL 4.1 server and have problems connecting to the database,
740 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
741 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
743 $ok = true; # Let's be optimistic
745 # Decide if we're going to use the superuser or the regular database user
746 $conf->Root
= $useRoot;
748 $db_user = $conf->RootUser
;
749 $db_pass = $conf->RootPW
;
751 $db_user = $wgDBuser;
752 $db_pass = $wgDBpassword;
756 echo( "<li>Attempting to connect to database server as $db_user..." );
757 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
759 # Check the connection and respond to errors
760 if( $wgDatabase->isOpen() ) {
763 $wgDBadminuser = $db_user;
764 $wgDBadminpassword = $db_pass;
765 echo( "success.</li>\n" );
766 $wgDatabase->ignoreErrors( true );
767 $myver = $wgDatabase->getServerVersion();
769 # There were errors, report them and back out
771 $errno = mysql_errno();
772 $errtx = htmlspecialchars( mysql_error() );
776 echo( "failed due to authentication errors. Check passwords.</li>" );
778 # The superuser details are wrong
779 $errs["RootUser"] = "Check username";
780 $errs["RootPW"] = "and password";
782 # The regular user details are wrong
783 $errs["DBuser"] = "Check username";
784 $errs["DBpassword"] = "and password";
790 # General connection problem
791 echo( "failed with error [$errno] $errtx.</li>\n" );
792 $errs["DBserver"] = "Connection failed";
797 if( !$ok ) { continue; }
799 } else /* not mysql */ {
800 error_reporting( E_ALL
);
802 ## Possible connect as a superuser
804 $wgDBsuperuser = $conf->RootUser
;
805 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
806 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
807 if (!$wgDatabase->isOpen()) {
808 print " error: " . $wgDatabase->lastError() . "</li>\n";
809 $errs["DBserver"] = "Could not connect to database as superuser";
810 $errs["RootUser"] = "Check username";
811 $errs["RootPW"] = "and password";
815 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
816 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
817 if (!$wgDatabase->isOpen()) {
818 print " error: " . $wgDatabase->lastError() . "</li>\n";
820 $myver = $wgDatabase->getServerVersion();
824 if ( !$wgDatabase->isOpen() ) {
825 $errs["DBserver"] = "Couldn't connect to database";
829 print "<li>Connected to $myver";
830 if ($conf->DBtype
== 'mysql') {
831 if( version_compare( $myver, "4.0.14" ) < 0 ) {
832 dieout( " -- mysql 4.0.14 or later required. Aborting." );
834 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
835 if( $mysqlNewAuth && $mysqlOldClient ) {
836 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
837 to old client libraries; if you have trouble with authentication, see
838 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
839 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
842 if( $mysqlNewAuth ) {
843 print "; enabling MySQL 4.1/5.0 charset mode";
845 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
846 but older version detected; will likely fail.</b>";
851 @$sel = $wgDatabase->selectDB( $wgDBname );
853 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
855 $err = mysql_errno();
856 $databaseSafe = htmlspecialchars( $wgDBname );
857 if( $err == 1102 /* Invalid database name */ ) {
858 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
860 } elseif( $err != 1049 /* Database doesn't exist */ ) {
861 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
862 print htmlspecialchars( mysql_error() ) . "</li></ul>";
865 print "<li>Attempting to create database...</li>";
866 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
868 print "<li>Couldn't create database <tt>" .
869 htmlspecialchars( $wgDBname ) .
870 "</tt>; try with root access or check your username/pass.</li>\n";
871 $errs["RootPW"] = "<- Enter";
874 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
876 $wgDatabase->selectDB( $wgDBname );
878 else if ($conf->DBtype
== 'postgres') {
879 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
880 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
884 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
885 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
887 if ( $conf->DBtype
== 'mysql') {
889 # Determine existing default character set
890 if ( $wgDatabase->tableExists( "revision" ) ) {
891 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
892 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
893 $row = $wgDatabase->fetchObject( $res );
895 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
896 $existingSchema = false;
897 } elseif ( preg_match( '/^latin1/', $row->Collation
) ) {
898 $existingSchema = 'mysql4';
899 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
900 $existingSchema = 'mysql5';
901 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
902 $existingSchema = 'mysql5-binary';
904 $existingSchema = false;
905 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
907 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
908 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
909 "but the existing database has the $existingSchema schema. This upgrade script ".
910 "can't convert it, so it will remain $existingSchema.</li>\n";
911 $conf->setSchema( $existingSchema );
915 # Create user if required
917 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
918 if ( $conn->isOpen() ) {
919 print "<li>DB user account ok</li>\n";
922 print "<li>Granting user permissions...";
923 if( $mysqlOldClient && $mysqlNewAuth ) {
924 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>";
927 dbsource( "../maintenance/users.sql", $wgDatabase );
931 print "</ul><pre>\n";
937 print "<ul><li>Finished update checks.</li>\n";
939 # FIXME: Check for errors
940 print "<li>Creating tables...";
941 if ($conf->DBtype
== 'mysql') {
942 dbsource( "../maintenance/tables.sql", $wgDatabase );
943 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
944 } else if ($conf->DBtype
== 'postgres') {
945 $wgDatabase->setup_database();
948 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
952 print " done.</li>\n";
954 print "<li>Initializing data...</li>\n";
955 $wgDatabase->insert( 'site_stats',
956 array ( 'ss_row_id' => 1,
957 'ss_total_views' => 0,
958 'ss_total_edits' => 0,
959 'ss_good_articles' => 0 ) );
961 # Set up the "regular user" account *if we can, and if we need to*
962 if( $conf->Root
and $conf->DBtype
== 'mysql') {
964 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
965 if( $wgDatabase2->isOpen() ) {
966 # Nope, just close the test connection and continue
967 $wgDatabase2->close();
968 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
970 # Yes, so run the grants
971 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
972 dbsource( "../maintenance/users.sql", $wgDatabase );
973 echo( "success.</li>\n" );
977 if( $conf->SysopName
) {
978 $u = User
::newFromName( $conf->getSysopName() );
980 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
982 else if ( 0 == $u->idForName() ) {
984 $u->setPassword( $conf->getSysopPass() );
987 $u->addGroup( "sysop" );
988 $u->addGroup( "bureaucrat" );
990 print "<li>Created sysop account <tt>" .
991 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
993 print "<li>Could not create user - already exists!</li>\n";
996 print "<li>Skipped sysop account creation, no name given.</li>\n";
999 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1000 $article = new Article( $titleobj );
1001 $newid = $article->insertOn( $wgDatabase );
1002 $revision = new Revision( array(
1004 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1007 'user_text' => 'MediaWiki default',
1009 $revid = $revision->insertOn( $wgDatabase );
1010 $article->updateRevisionOn( $wgDatabase, $revision );
1013 /* Write out the config file now that all is well */
1014 print "<li style=\"list-style: none\">\n";
1015 print "<p>Creating LocalSettings.php...</p>\n\n";
1016 $localSettings = "<" . "?php$endl$local";
1017 // Fix up a common line-ending problem (due to CVS on Windows)
1018 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1019 $f = fopen( "LocalSettings.php", 'xt' );
1022 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" .
1023 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1024 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1026 if(fwrite( $f, $localSettings ) ) {
1028 writeSuccessMessage();
1031 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");
1044 if( count( $errs ) ) {
1045 /* Display options form */
1047 if( $conf->posted
) {
1048 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1052 <form action
="index.php" name
="config" method
="post">
1055 <h2
>Site config
</h2
>
1057 <div
class="config-section">
1058 <div
class="config-input">
1060 aField( $conf, "Sitename", "Wiki name:" );
1063 <p
class="config-desc">
1064 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1065 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1068 <div
class="config-input">
1070 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1073 <p
class="config-desc">
1074 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
.
1077 <div
class="config-input">
1078 <label
class='column' for="LanguageCode">Language
:</label
>
1079 <select id
="LanguageCode" name
="LanguageCode">
1082 $list = getLanguageList();
1083 foreach( $list as $code => $name ) {
1084 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1085 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1090 <p
class="config-desc">
1091 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1094 <div
class="config-input">
1095 <label
class='column'>Copyright
/license
:</label
>
1098 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1099 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1101 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1102 $partner = "MediaWiki";
1103 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1104 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1105 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1106 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1108 <?php
if( $conf->License
== "cc" ) { ?
>
1110 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1111 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1112 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1113 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1119 <p
class="config-desc">
1120 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1124 <div
class="config-input">
1125 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1127 <div
class="config-input">
1128 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1130 <div
class="config-input">
1131 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1133 <p
class="config-desc">
1134 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1135 A
new account will be added only when creating a
new wiki database
.
1137 The password cannot be the same
as the username
.
1140 <div
class="config-input">
1141 <label
class='column'>Shared memory caching
:</label
>
1144 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1146 if ( $conf->turck
) {
1148 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1151 if( $conf->xcache
) {
1153 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1158 aField( $conf, "Shm", "APC", "radio", "apc" );
1161 if ( $conf->eaccel
) {
1163 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1167 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1169 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1171 <p
class="config-desc">
1172 An
object caching system such
as memcached will provide a significant performance boost
,
1173 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1175 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1176 these should not be used
if the wiki will be running on multiple application servers
.
1180 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1182 <div
class="config-section">
1183 <div
class="config-input">
1184 <label
class='column'>E
-mail
features (global):</label
>
1186 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1187 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1190 <p
class="config-desc">
1191 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1192 if sending mail doesn
't work on your server.
1195 <div class="config-input">
1196 <label class='column
'>User-to-user e-mail:</label>
1198 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1199 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1202 <p class="config-desc">
1203 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.
1205 <div class="config-input">
1206 <label class='column
'>E-mail notification about changes:</label>
1208 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1209 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1210 <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>
1213 <div class="config-desc">
1215 For this feature to work, an e-mail address must be present for the user account, and the notification
1216 options in the user's preferences must be enabled
. Also note the
1217 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1219 <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
>
1222 <div
class="config-input">
1223 <label
class='column'>E
-mail address authentication
:</label
>
1225 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1226 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1229 <div
class="config-desc">
1230 <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
1231 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1236 <h2
>Database config
</h2
>
1238 <div
class="config-section">
1239 <div
class="config-input">
1240 <label
class='column'>Database type
:</label
>
1241 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1242 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1245 <div
class="config-input" style
="clear:left"><?php
1246 aField( $conf, "DBserver", "Database host:" );
1248 <p
class="config-desc">
1249 If your database server isn
't on your web server, enter the name or IP address here.
1252 <div class="config-input"><?php
1253 aField( $conf, "DBname", "Database name:" );
1255 <div class="config-input"><?php
1256 aField( $conf, "DBuser", "DB username:" );
1258 <div class="config-input"><?php
1259 aField( $conf, "DBpassword", "DB password:", "password" );
1261 <div class="config-input"><?php
1262 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1264 <p class="config-desc">
1265 If you only have a single user account and database available,
1266 enter those here. If you have database root access (see below)
1267 you can specify new accounts/databases to be created. This account
1268 will not be created if it pre-exists. If this is the case, ensure that it
1269 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1272 <div class="config-input">
1273 <label class="column">Superuser account:</label>
1274 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1275 <label for="useroot">Use superuser account</label>
1277 <div class="config-input">
1279 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1282 <div class="config-input">
1284 aField( $conf, "RootPW", "Superuser password:", "password" );
1288 <p class="config-desc">
1289 If the database user specified above does not exist, or does not have access to create
1290 the database (if needed) or tables within it, please check the box and provide details
1291 of a superuser account, such as <strong>root</strong>, which does.
1294 <?php database_switcher('mysql
'); ?>
1295 <div class="config-input"><?php
1296 aField( $conf, "DBprefix", "Database table prefix:" );
1298 <div class="config-desc">
1299 <p>If you need to share one database between multiple wikis, or
1300 between MediaWiki and another web application, you may choose to
1301 add a prefix to all the table names to avoid conflicts.</p>
1303 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1306 <div class="config-input"><label class="column">Database charset</label>
1307 <div>Select one:</div>
1309 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1310 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1311 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1314 <p class="config-desc">
1315 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1316 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1317 cause things to break. <b>If upgrading an older installation, leave
1318 in backwards-compatible mode.</b>
1322 <?php database_switcher('postgres
'); ?>
1323 <div class="config-input"><?php
1324 aField( $conf, "DBport", "Database port:" );
1326 <div class="config-input"><?php
1327 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1329 <div class="config-input"><?php
1330 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1332 <div class="config-desc">
1333 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1334 so it is recommended that you create a new user. The above schemas are generally correct:
1335 only change them if you are sure you need to.</p>
1339 <div class="config-input" style="padding:2em 0 3em">
1340 <label class='column
'> </label>
1341 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1346 <script type="text/javascript">
1347 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1349 ## If they passed in a root user name, don't populate it on page load
1350 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1359 /* -------------------------------------------------------------------------------------- */
1360 function writeSuccessMessage() {
1361 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1363 <p>Installation successful!</p>
1364 <p>To complete the installation, please do the following:
1366 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1367 <li>Upload it to the parent directory</li>
1368 <li>Delete config/LocalSettings.php</li>
1369 <li>Start using <a href='../index.php'>your wiki</a>!
1371 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1372 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1373 which means that anyone on the same server can read your database password! Downloading
1374 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1379 <span class="success-message">Installation successful!</span>
1380 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1381 <a href="../index.php"> this link</a> to your wiki.</p>
1382 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1383 prevent other users on the server reading passwords and altering configuration data.</p>
1389 function escapePhpString( $string ) {
1390 return strtr( $string,
1401 function writeLocalSettings( $conf ) {
1402 $conf->PasswordSender
= $conf->EmergencyContact
;
1403 $magic = ($conf->ImageMagick ?
"" : "# ");
1404 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1405 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1406 $hashedUploads = $conf->safeMode ?
'' : '# ';
1408 switch ( $conf->Shm
) {
1410 $cacheType = 'CACHE_MEMCACHED';
1411 $mcservers = var_export( $conf->MCServerArray
, true );
1417 $cacheType = 'CACHE_ACCEL';
1418 $mcservers = 'array()';
1421 $cacheType = 'CACHE_NONE';
1422 $mcservers = 'array()';
1425 if ( $conf->Email
== 'email_enabled' ) {
1426 $enableemail = 'true';
1427 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1428 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1429 switch ( $conf->Enotif
) {
1430 case 'enotif_usertalk':
1431 $enotifusertalk = 'true';
1432 $enotifwatchlist = 'false';
1434 case 'enotif_allpages':
1435 $enotifusertalk = 'true';
1436 $enotifwatchlist = 'true';
1439 $enotifusertalk = 'false';
1440 $enotifwatchlist = 'false';
1443 $enableuseremail = 'false';
1444 $enableemail = 'false';
1445 $eauthent = 'false';
1446 $enotifusertalk = 'false';
1447 $enotifwatchlist = 'false';
1450 $file = @fopen
( "/dev/urandom", "r" );
1452 $secretKey = bin2hex( fread( $file, 32 ) );
1456 for ( $i=0; $i<8; $i++
) {
1457 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1459 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1462 # Add slashes to strings for double quoting
1463 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1464 if( $conf->License
== 'gfdl' ) {
1465 # Needs literal string interpolation for the current style path
1466 $slconf['RightsIcon'] = $conf->RightsIcon
;
1470 # This file was automatically generated by the MediaWiki installer.
1471 # If you make manual changes, please keep track in case you need to
1472 # recreate them later.
1474 # See includes/DefaultSettings.php for all configurable settings
1475 # and their default values, but don't forget to make changes in _this_
1478 # If you customize your file layout, set \$IP to the directory that contains
1479 # the other MediaWiki files. It will be used as a base to locate files.
1480 if( defined( 'MW_INSTALL_PATH' ) ) {
1481 \$IP = MW_INSTALL_PATH;
1483 \$IP = dirname( __FILE__ );
1486 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1487 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1489 require_once( \"includes/DefaultSettings.php\" );
1491 # If PHP's memory limit is very low, some operations may fail.
1492 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1494 if ( \$wgCommandLineMode ) {
1495 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1496 die( \"This script must be run from the command line\\n\" );
1499 ## Uncomment this to disable output compression
1500 # \$wgDisableOutputCompression = true;
1502 \$wgSitename = \"{$slconf['Sitename']}\";
1504 ## The URL base path to the directory containing the wiki;
1505 ## defaults for all runtime URL paths are based off of this.
1506 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1508 ## For more information on customizing the URLs please see:
1509 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1511 \$wgEnableEmail = $enableemail;
1512 \$wgEnableUserEmail = $enableuseremail;
1514 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1515 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1517 ## For a detailed description of the following switches see
1518 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1519 ## There are many more options for fine tuning available see
1520 ## /includes/DefaultSettings.php
1521 ## UPO means: this is also a user preference option
1522 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1523 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1524 \$wgEmailAuthentication = $eauthent;
1526 \$wgDBtype = \"{$slconf['DBtype']}\";
1527 \$wgDBserver = \"{$slconf['DBserver']}\";
1528 \$wgDBname = \"{$slconf['DBname']}\";
1529 \$wgDBuser = \"{$slconf['DBuser']}\";
1530 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1532 # MySQL specific settings
1533 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1535 # MySQL table options to use during installation or update
1536 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1538 # Experimental charset support for MySQL 4.1/5.0.
1539 \$wgDBmysql5 = {$conf->DBmysql5};
1541 # Postgres specific settings
1542 \$wgDBport = \"{$slconf['DBport']}\";
1543 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1544 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1546 ## Shared memory settings
1547 \$wgMainCacheType = $cacheType;
1548 \$wgMemCachedServers = $mcservers;
1550 ## To enable image uploads, make sure the 'images' directory
1551 ## is writable, then set this to true:
1552 \$wgEnableUploads = false;
1553 {$magic}\$wgUseImageMagick = true;
1554 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1556 ## If you want to use image uploads under safe mode,
1557 ## create the directories images/archive, images/thumb and
1558 ## images/temp, and make them all writable. Then uncomment
1559 ## this, if it's not already uncommented:
1560 {$hashedUploads}\$wgHashedUploadDirectory = false;
1562 ## If you have the appropriate support software installed
1563 ## you can enable inline LaTeX equations:
1566 \$wgLocalInterwiki = \$wgSitename;
1568 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1570 \$wgProxyKey = \"$secretKey\";
1572 ## Default skin: you can change the default skin. Use the internal symbolic
1573 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1574 \$wgDefaultSkin = 'monobook';
1576 ## For attaching licensing metadata to pages, and displaying an
1577 ## appropriate copyright notice / icon. GNU Free Documentation
1578 ## License and Creative Commons licenses are supported so far.
1579 {$rights}\$wgEnableCreativeCommonsRdf = true;
1580 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1581 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1582 \$wgRightsText = \"{$slconf['RightsText']}\";
1583 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1584 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1586 \$wgDiff3 = \"{$slconf['diff3']}\";
1588 # When you make changes to this configuration file, this will make
1589 # sure that cached pages are cleared.
1590 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1591 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1592 "; ## End of setting the $localsettings string
1594 // Keep things in Unix line endings internally;
1595 // the system will write out as local text type.
1596 return str_replace( "\r\n", "\n", $localsettings );
1599 function dieout( $text ) {
1600 die( $text . "\n\n</body>\n</html>" );
1603 function importVar( &$var, $name, $default = "" ) {
1604 if( isset( $var[$name] ) ) {
1605 $retval = $var[$name];
1606 if ( get_magic_quotes_gpc() ) {
1607 $retval = stripslashes( $retval );
1615 function importPost( $name, $default = "" ) {
1616 return importVar( $_POST, $name, $default );
1619 function importCheck( $name ) {
1620 return isset( $_POST[$name] );
1623 function importRequest( $name, $default = "" ) {
1624 return importVar( $_REQUEST, $name, $default );
1629 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1632 $xtype = "type=\"$type\"";
1638 $nolabel = ($type == "radio") ||
($type == "hidden");
1640 if ($type == 'radio')
1641 $id .= $radioCount++
;
1646 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1649 if( $type == "radio" && $value == $conf->$field ) {
1650 $checked = "checked='checked'";
1654 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1656 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1659 if( $type == "radio" ) {
1660 echo htmlspecialchars( $value );
1662 echo htmlspecialchars( $conf->$field );
1668 echo " $text</label>\n";
1672 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1675 function getLanguageList() {
1676 global $wgLanguageNames;
1677 if( !isset( $wgLanguageNames ) ) {
1678 require_once( "languages/Names.php" );
1683 $d = opendir( "../languages/messages" );
1684 /* In case we are called from the root directory */
1686 $d = opendir( "languages/messages");
1687 while( false !== ($f = readdir( $d ) ) ) {
1689 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1690 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1691 if( isset( $wgLanguageNames[$code] ) ) {
1692 $name = $code . ' - ' . $wgLanguageNames[$code];
1696 $codes[$code] = $name;
1704 #Check for location of an executable
1705 # @param string $loc single location to check
1706 # @param array $names filenames to check for.
1707 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1708 function locate_executable($loc, $names, $versioninfo = false) {
1709 if (!is_array($names))
1710 $names = array($names);
1712 foreach ($names as $name) {
1713 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1714 if (file_exists($command)) {
1718 $file = str_replace('$1', $command, $versioninfo[0]);
1719 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1726 # Test a memcached server
1727 function testMemcachedServer( $server ) {
1728 $hostport = explode(":", $server);
1731 if ( !function_exists( 'fsockopen' ) ) {
1732 $errstr = "Can't connect to memcached, fsockopen() not present";
1734 if ( !$errstr && count( $hostport ) != 2 ) {
1735 $errstr = 'Please specify host and port';
1736 var_dump( $hostport );
1739 list( $host, $port ) = $hostport;
1743 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1744 if ( $fp === false ) {
1745 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1749 $command = "version\r\n";
1750 $bytes = fwrite( $fp, $command );
1751 if ( $bytes != strlen( $command ) ) {
1752 $errstr = "Cannot write to memcached socket on $host:$port";
1756 $expected = "VERSION ";
1757 $response = fread( $fp, strlen( $expected ) );
1758 if ( $response != $expected ) {
1759 $errstr = "Didn't get correct memcached response from $host:$port";
1766 echo "<li>Connected to memcached on $host:$port successfully";
1771 function database_picker($conf) {
1774 foreach(array_keys($ourdb) as $db) {
1775 if ($ourdb[$db]['havedriver']) {
1777 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1784 function database_switcher($db) {
1786 $color = $ourdb[$db]['bgcolor'];
1787 $full = $ourdb[$db]['fullname'];
1788 print "<div id='$db' style='display:none; background: $color'>\n";
1789 print "<h3>$full specific options:</h3>\n";
1792 function printListItem( $item ) {
1793 print "<li>$item</li>";
1798 <div
class="license">
1800 <p
>This program is free software
; you can redistribute it
and/or modify
1801 it under the terms of the GNU General
Public License
as published by
1802 the Free Software Foundation
; either version
2 of the License
, or
1803 (at your option
) any later version
.</p
>
1805 <p
>This program is distributed in the hope that it will be useful
,
1806 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1807 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1808 GNU General
Public License
for more details
.</p
>
1810 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1811 along with this program
; if not
, write to the Free Software
1812 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1813 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1819 <div id
="column-one">
1820 <div
class="portlet" id
="p-logo">
1821 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1822 href
="http://www.mediawiki.org/"
1823 title
="Main Page"></a
>
1825 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1826 <div
class='portlet'><div
class='pBody'>
1828 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1829 <li
><a href
="../README">Readme
</a
></li
>
1830 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1831 <li
><a href
="../docs/">Documentation
</a
></li
>
1832 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1833 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1835 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2007 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>