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
;
157 span
.success
-message
{
164 <script type
="text/javascript">
167 <?php
foreach (array_keys($ourdb) as $db) {
168 echo "\n document.getElementById('$db').style.display='none';";
173 function toggleDBarea(id
,defaultroot
) {
175 var dbarea
= document
.getElementById(id
).style
;
176 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
177 var db
= document
.getElementById('RootUser');
179 <?php
foreach (array_keys($ourdb) as $db) {
180 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
189 <div id
="globalWrapper">
190 <div id
="column-content">
192 <div id
="bodyContent">
194 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
198 /* Check for existing configurations and bug out! */
200 if( file_exists( "../LocalSettings.php" ) ) {
201 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
203 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
206 if( file_exists( "./LocalSettings.php" ) ) {
207 writeSuccessMessage();
212 if( !is_writable( "." ) ) {
213 dieout( "<h2>Can't write config file, aborting</h2>
215 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
216 writable by the web server. Once configuration is done you'll move the created
217 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
218 then remove the <tt>config</tt> subdirectory entirely.</p>
220 <p>To make the directory writable on a Unix/Linux system:</p>
223 cd <i>/path/to/wiki</i>
227 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
231 require_once( "install-utils.inc" );
232 require_once( "maintenance/updaters.inc" );
235 function getEncoded( $data ) {
236 # removing latin1 support, no need...
239 function getSitename() { return $this->getEncoded( $this->Sitename
); }
240 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
241 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
243 function setSchema( $schema ) {
244 $this->DBschema
= $schema;
245 switch ( $this->DBschema
) {
247 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
248 $this->DBmysql5
= 'true';
250 case 'mysql5-binary':
251 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
252 $this->DBmysql5
= 'true';
255 $this->DBTableOptions
= 'TYPE=InnoDB';
256 $this->DBmysql5
= 'false';
258 # Set the global for use during install
259 global $wgDBTableOptions;
260 $wgDBTableOptions = $this->DBTableOptions
;
268 <b
>Don
't forget security updates!</b> Keep an eye on the
269 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
270 release announcements mailing list</a>.
275 <h2>Checking environment...</h2>
276 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
277 <ul class="env-check">
281 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
282 $conf = new ConfigData;
284 install_version_checks();
285 $self = 'Installer
'; # Maintenance script name, to please Setup.php
287 print "<li>PHP " . phpversion() . " installed</li>\n";
289 error_reporting( 0 );
290 $phpdatabases = array();
291 foreach (array_keys($ourdb) as $db) {
292 $compname = $ourdb[$db]['compile
'];
293 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
294 array_push($phpdatabases, $db);
295 $ourdb[$db]['havedriver
'] = 1;
298 error_reporting( E_ALL );
300 if (!$phpdatabases) {
301 print "Could not find a suitable database driver!<ul>";
302 foreach (array_keys($ourdb) AS $db) {
303 $comp = $ourdb[$db]['compile
'];
304 $full = $ourdb[$db]['fullname
'];
305 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
306 ."or install the $comp.so module</li>\n";
308 dieout( "</ul></ul>" );
311 print "<li>Found database drivers for:";
312 foreach (array_keys($ourdb) AS $db) {
313 if ($ourdb[$db]['havedriver
']) {
314 $DefaultDBtype = $db;
315 print " ".$ourdb[$db]['fullname
'];
319 if (count($phpdatabases) != 1)
322 if( ini_get( "register_globals" ) ) {
325 <div style="font-size:110%">
326 <strong class="error">Warning:</strong>
327 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
329 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
336 if( ini_get( "magic_quotes_runtime" ) ) {
338 ?
><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
>
339 This option corrupts data input unpredictably
; you cannot install
or use
340 MediaWiki unless this option is disabled
.
344 if( ini_get( "magic_quotes_sybase" ) ) {
346 ?
><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
>
347 This option corrupts data input unpredictably
; you cannot install
or use
348 MediaWiki unless this option is disabled
.
352 if( ini_get( "mbstring.func_overload" ) ) {
354 ?
><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
>
355 This option causes errors
and may corrupt data unpredictably
;
356 you cannot install
or use MediaWiki unless this option is disabled
.
360 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
362 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
363 This option causes horrible bugs with MediaWiki
; you cannot install
or use
364 MediaWiki unless this option is disabled
.
370 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
373 if( ini_get( "safe_mode" ) ) {
374 $conf->safeMode
= true;
376 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
377 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
378 You may have problems caused by this
, particularly
if using image uploads
.
382 $conf->safeMode
= false;
385 $sapi = php_sapi_name();
386 print "<li>PHP server API is $sapi; ";
387 if( $wgUsePathInfo ) {
388 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
390 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
394 $conf->xml
= function_exists( "utf8_encode" );
396 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
398 dieout( "PHP's XML module is missing; the wiki requires functions in
399 this module and won't work in this configuration.
400 If you're running Mandrake, install the php-xml package." );
403 # Check for session support
404 if( !function_exists( 'session_name' ) )
405 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
407 # session.save_path doesn't *have* to be set, but if it is, and it's
408 # not valid/writable/etc. then it can cause problems
409 $sessionSavePath = mw_get_session_save_path();
410 $ssp = htmlspecialchars( $sessionSavePath );
411 # Warn the user if it's not set, but let them proceed
412 if( !$sessionSavePath ) {
413 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
414 has not been set in PHP.ini. If the default value causes problems with
415 saving session data, set it to a valid path which is read/write/execute
416 for the user your web server is running under.</li>";
417 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
418 # All good? Let the user know
419 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
421 # Something not right? Warn the user, but let them proceed
422 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
423 appears to be invalid or is not writable. PHP needs to be able to save data to
424 this location for correct session operation.</li>";
427 # Check for PCRE support
428 if( !function_exists( 'preg_match' ) )
429 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
430 Perl-compatible regular expression functions." );
432 $memlimit = ini_get( "memory_limit" );
433 $conf->raiseMemory
= false;
434 if( empty( $memlimit ) ||
$memlimit == -1 ) {
435 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
437 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
438 $n = intval( $memlimit );
439 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
440 $n = intval( $m[1] * (1024*1024) );
442 if( $n < 20*1024*1024 ) {
443 print "Attempting to raise limit to 20M... ";
444 if( false === ini_set( "memory_limit", "20M" ) ) {
445 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
447 $conf->raiseMemory
= true;
454 $conf->turck
= function_exists( 'mmcache_get' );
455 if ( $conf->turck
) {
456 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
459 $conf->xcache
= function_exists( 'xcache_get' );
461 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
463 $conf->apc
= function_exists('apc_fetch');
465 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
468 $conf->eaccel
= function_exists( 'eaccelerator_get' );
469 if ( $conf->eaccel
) {
470 $conf->turck
= 'eaccelerator';
471 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
474 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
475 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
476 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
477 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>.
478 Object caching functions cannot be used.</li>' );
481 $conf->diff3
= false;
482 $diff3locations = array_merge(
489 explode( $sep, getenv( "PATH" ) ) );
490 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
492 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
493 foreach ($diff3locations as $loc) {
494 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
495 if ($exe !== false) {
502 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
504 print "<li>GNU diff3 not found.</li>";
506 $conf->ImageMagick
= false;
507 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
508 foreach( $imcheck as $dir ) {
509 $im = "$dir/convert";
510 if( file_exists( $im ) ) {
511 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
512 $conf->ImageMagick
= $im;
517 $conf->HaveGD
= function_exists( "imagejpeg" );
518 if( $conf->HaveGD
) {
519 print "<li>Found GD graphics library built-in";
520 if( !$conf->ImageMagick
) {
521 print ", image thumbnailing will be enabled if you enable uploads";
525 if( !$conf->ImageMagick
) {
526 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
530 $conf->IP
= dirname( dirname( __FILE__
) );
531 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
534 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
535 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
536 // to get the path to the current script... hopefully it's reliable. SIGH
537 $path = ($_SERVER["PHP_SELF"] === '')
538 ?
$_SERVER["SCRIPT_NAME"]
539 : $_SERVER["PHP_SELF"];
540 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
541 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
543 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
544 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
546 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
547 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
549 : $_SERVER["SERVER_ADMIN"];
550 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
551 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
555 $conf->DBserver
= importPost( "DBserver", "localhost" );
556 $conf->DBname
= importPost( "DBname", "wikidb" );
557 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
558 $conf->DBpassword
= importPost( "DBpassword" );
559 $conf->DBpassword2
= importPost( "DBpassword2" );
560 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
561 $conf->SysopPass
= importPost( "SysopPass" );
562 $conf->SysopPass2
= importPost( "SysopPass2" );
563 $conf->RootUser
= importPost( "RootUser", "root" );
564 $conf->RootPW
= importPost( "RootPW", "" );
565 $useRoot = importCheck( 'useroot', false );
566 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
569 $conf->DBprefix
= importPost( "DBprefix" );
570 $conf->setSchema( importPost( "DBschema", "mysql4" ) );
572 ## Postgres specific:
573 $conf->DBport
= importPost( "DBport", "5432" );
574 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
575 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
577 /* Check for validity */
580 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
581 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
583 if( $conf->DBuser
== "" ) {
584 $errs["DBuser"] = "Must not be blank";
586 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
587 $errs["DBuser"] = "Username too long";
589 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
590 $errs["DBpassword"] = "Must not be blank";
592 if( $conf->DBpassword
!= $conf->DBpassword2
) {
593 $errs["DBpassword2"] = "Passwords don't match!";
595 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
596 $errs["DBprefix"] = "Invalid table prefix";
599 error_reporting( E_ALL
);
602 * Initialise $wgLang and $wgContLang to something so we can
603 * call case-folding methods. Per Brion, this is English for
604 * now, although we could be clever and initialise to the
605 * user-selected language.
607 $wgContLang = Language
::factory( 'en' );
608 $wgLang = $wgContLang;
611 * We're messing about with users, so we need a stub
612 * authentication plugin...
614 $wgAuth = new AuthPlugin();
617 * Validate the initial administrator account; username,
618 * password checks, etc.
620 if( $conf->SysopName
) {
621 # Check that the user can be created
622 $u = User
::newFromName( $conf->SysopName
);
623 if( $u instanceof User
) {
624 # Various password checks
625 if( $conf->SysopPass
!= '' ) {
626 if( $conf->SysopPass
== $conf->SysopPass2
) {
627 if( !$u->isValidPassword( $conf->SysopPass
) ) {
628 $errs['SysopPass'] = "Bad password";
631 $errs['SysopPass2'] = "Passwords don't match";
634 $errs['SysopPass'] = "Cannot be blank";
638 $errs['SysopName'] = "Bad username";
642 $conf->License
= importRequest( "License", "none" );
643 if( $conf->License
== "gfdl" ) {
644 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
645 $conf->RightsText
= "GNU Free Documentation License 1.2";
646 $conf->RightsCode
= "gfdl";
647 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
648 } elseif( $conf->License
== "none" ) {
649 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
651 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
652 $conf->RightsText
= importRequest( "RightsText", "" );
653 $conf->RightsCode
= importRequest( "RightsCode", "" );
654 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
657 $conf->Shm
= importRequest( "Shm", "none" );
658 $conf->MCServers
= importRequest( "MCServers" );
660 /* Test memcached servers */
662 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
663 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
664 foreach ( $conf->MCServerArray
as $server ) {
665 $error = testMemcachedServer( $server );
667 $errs["MCServers"] = $error;
671 } else if ( $conf->Shm
== 'memcached' ) {
672 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
675 /* default values for installation */
676 $conf->Email
= importRequest("Email", "email_enabled");
677 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
678 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
679 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
681 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
682 do { /* So we can 'continue' to end prematurely */
683 $conf->Root
= ($conf->RootPW
!= "");
685 /* Load up the settings and get installin' */
686 $local = writeLocalSettings( $conf );
687 echo "<li style=\"list-style: none\">\n";
688 echo "<p><b>Generating configuration file...</b></p>\n";
691 $wgCommandLineMode = false;
693 $ok = eval( $local );
694 if( $ok === false ) {
695 dieout( "Errors in generated configuration; " .
696 "most likely due to a bug in the installer... " .
697 "Config file was: " .
699 htmlspecialchars( $local ) .
703 $conf->DBtypename
= '';
704 foreach (array_keys($ourdb) as $db) {
705 if ($conf->DBtype
=== $db)
706 $conf->DBtypename
= $ourdb[$db]['fullname'];
708 if ( ! strlen($conf->DBtype
)) {
709 $errs["DBpicktype"] = "Please choose a database type";
713 if (! $conf->DBtypename
) {
714 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
717 print "<li>Database type: {$conf->DBtypename}</li>\n";
718 $dbclass = 'Database'.ucfirst($conf->DBtype
);
719 $wgDBtype = $conf->DBtype
;
720 $wgDBadminuser = "root";
721 $wgDBadminpassword = $conf->RootPW
;
724 $wgDBprefix = $conf->DBprefix
;
726 ## Postgres specific:
727 $wgDBport = $conf->DBport
;
728 $wgDBmwschema = $conf->DBmwschema
;
729 $wgDBts2schema = $conf->DBts2schema
;
731 $wgCommandLineMode = true;
732 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
733 require_once( "includes/Setup.php" );
736 $wgTitle = Title
::newFromText( "Installation script" );
737 error_reporting( E_ALL
);
738 print "<li>Loading class: $dbclass";
741 if( $conf->DBtype
== 'mysql' ) {
742 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
743 if( $mysqlOldClient ) {
744 print "<li><b>PHP is linked with old MySQL client libraries. If you are
745 using a MySQL 4.1 server and have problems connecting to the database,
746 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
747 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
749 $ok = true; # Let's be optimistic
751 # Decide if we're going to use the superuser or the regular database user
752 $conf->Root
= $useRoot;
754 $db_user = $conf->RootUser
;
755 $db_pass = $conf->RootPW
;
757 $db_user = $wgDBuser;
758 $db_pass = $wgDBpassword;
762 echo( "<li>Attempting to connect to database server as $db_user..." );
763 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
765 # Check the connection and respond to errors
766 if( $wgDatabase->isOpen() ) {
769 $wgDBadminuser = $db_user;
770 $wgDBadminpassword = $db_pass;
771 echo( "success.</li>\n" );
772 $wgDatabase->ignoreErrors( true );
773 $myver = $wgDatabase->getServerVersion();
775 # There were errors, report them and back out
777 $errno = mysql_errno();
778 $errtx = htmlspecialchars( mysql_error() );
782 echo( "failed due to authentication errors. Check passwords.</li>" );
784 # The superuser details are wrong
785 $errs["RootUser"] = "Check username";
786 $errs["RootPW"] = "and password";
788 # The regular user details are wrong
789 $errs["DBuser"] = "Check username";
790 $errs["DBpassword"] = "and password";
796 # General connection problem
797 echo( "failed with error [$errno] $errtx.</li>\n" );
798 $errs["DBserver"] = "Connection failed";
803 if( !$ok ) { continue; }
805 } else /* not mysql */ {
806 error_reporting( E_ALL
);
808 ## Possible connect as a superuser
810 $wgDBsuperuser = $conf->RootUser
;
811 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
812 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
813 if (!$wgDatabase->isOpen()) {
814 print " error: " . $wgDatabase->lastError() . "</li>\n";
815 $errs["DBserver"] = "Could not connect to database as superuser";
816 $errs["RootUser"] = "Check username";
817 $errs["RootPW"] = "and password";
821 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
822 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
823 if (!$wgDatabase->isOpen()) {
824 print " error: " . $wgDatabase->lastError() . "</li>\n";
826 $myver = $wgDatabase->getServerVersion();
830 if ( !$wgDatabase->isOpen() ) {
831 $errs["DBserver"] = "Couldn't connect to database";
835 print "<li>Connected to $myver";
836 if ($conf->DBtype
== 'mysql') {
837 if( version_compare( $myver, "4.0.14" ) < 0 ) {
838 dieout( " -- mysql 4.0.14 or later required. Aborting." );
840 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
841 if( $mysqlNewAuth && $mysqlOldClient ) {
842 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
843 to old client libraries; if you have trouble with authentication, see
844 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
845 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
848 if( $mysqlNewAuth ) {
849 print "; enabling MySQL 4.1/5.0 charset mode";
851 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
852 but older version detected; will likely fail.</b>";
857 @$sel = $wgDatabase->selectDB( $wgDBname );
859 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
861 $err = mysql_errno();
862 $databaseSafe = htmlspecialchars( $wgDBname );
863 if( $err == 1102 /* Invalid database name */ ) {
864 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
866 } elseif( $err != 1049 /* Database doesn't exist */ ) {
867 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
868 print htmlspecialchars( mysql_error() ) . "</li></ul>";
871 print "<li>Attempting to create database...</li>";
872 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
874 print "<li>Couldn't create database <tt>" .
875 htmlspecialchars( $wgDBname ) .
876 "</tt>; try with root access or check your username/pass.</li>\n";
877 $errs["RootPW"] = "<- Enter";
880 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
882 $wgDatabase->selectDB( $wgDBname );
884 else if ($conf->DBtype
== 'postgres') {
885 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
886 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
890 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
891 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
893 if ( $conf->DBtype
== 'mysql') {
895 # Determine existing default character set
896 if ( $wgDatabase->tableExists( "revision" ) ) {
897 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
898 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
899 $row = $wgDatabase->fetchObject( $res );
901 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
902 $existingSchema = false;
903 } elseif ( preg_match( '/^latin1/', $row->Collation
) ) {
904 $existingSchema = 'mysql4';
905 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
906 $existingSchema = 'mysql5';
907 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
908 $existingSchema = 'mysql5-binary';
910 $existingSchema = false;
911 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
913 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
914 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
915 "but the existing database has the $existingSchema schema. This upgrade script ".
916 "can't convert it, so it will remain $existingSchema.</li>\n";
917 $conf->setSchema( $existingSchema );
921 # Create user if required
923 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
924 if ( $conn->isOpen() ) {
925 print "<li>DB user account ok</li>\n";
928 print "<li>Granting user permissions...";
929 if( $mysqlOldClient && $mysqlNewAuth ) {
930 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>";
933 dbsource( "../maintenance/users.sql", $wgDatabase );
937 print "</ul><pre>\n";
943 print "<ul><li>Finished update checks.</li>\n";
945 # FIXME: Check for errors
946 print "<li>Creating tables...";
947 if ($conf->DBtype
== 'mysql') {
948 dbsource( "../maintenance/tables.sql", $wgDatabase );
949 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
950 } else if ($conf->DBtype
== 'postgres') {
951 $wgDatabase->setup_database();
954 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
958 print " done.</li>\n";
960 print "<li>Initializing data...</li>\n";
961 $wgDatabase->insert( 'site_stats',
962 array ( 'ss_row_id' => 1,
963 'ss_total_views' => 0,
964 'ss_total_edits' => 0,
965 'ss_good_articles' => 0 ) );
967 # Set up the "regular user" account *if we can, and if we need to*
968 if( $conf->Root
and $conf->DBtype
== 'mysql') {
970 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
971 if( $wgDatabase2->isOpen() ) {
972 # Nope, just close the test connection and continue
973 $wgDatabase2->close();
974 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
976 # Yes, so run the grants
977 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
978 dbsource( "../maintenance/users.sql", $wgDatabase );
979 echo( "success.</li>\n" );
983 if( $conf->SysopName
) {
984 $u = User
::newFromName( $conf->getSysopName() );
986 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
988 else if ( 0 == $u->idForName() ) {
990 $u->setPassword( $conf->getSysopPass() );
993 $u->addGroup( "sysop" );
994 $u->addGroup( "bureaucrat" );
996 print "<li>Created sysop account <tt>" .
997 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
999 print "<li>Could not create user - already exists!</li>\n";
1002 print "<li>Skipped sysop account creation, no name given.</li>\n";
1005 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1006 $article = new Article( $titleobj );
1007 $newid = $article->insertOn( $wgDatabase );
1008 $revision = new Revision( array(
1010 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1013 'user_text' => 'MediaWiki default',
1015 $revid = $revision->insertOn( $wgDatabase );
1016 $article->updateRevisionOn( $wgDatabase, $revision );
1019 /* Write out the config file now that all is well */
1020 print "<li style=\"list-style: none\">\n";
1021 print "<p>Creating LocalSettings.php...</p>\n\n";
1022 $localSettings = "<" . "?php$endl$local";
1023 // Fix up a common line-ending problem (due to CVS on Windows)
1024 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1025 $f = fopen( "LocalSettings.php", 'xt' );
1028 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" .
1029 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1030 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1032 if(fwrite( $f, $localSettings ) ) {
1034 writeSuccessMessage();
1037 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");
1050 if( count( $errs ) ) {
1051 /* Display options form */
1053 if( $conf->posted
) {
1054 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1058 <form action
="index.php" name
="config" method
="post">
1061 <h2
>Site config
</h2
>
1063 <div
class="config-section">
1064 <div
class="config-input">
1066 aField( $conf, "Sitename", "Wiki name:" );
1069 <p
class="config-desc">
1070 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1071 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1074 <div
class="config-input">
1076 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1079 <p
class="config-desc">
1080 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
.
1083 <div
class="config-input">
1084 <label
class='column' for="LanguageCode">Language
:</label
>
1085 <select id
="LanguageCode" name
="LanguageCode">
1088 $list = getLanguageList();
1089 foreach( $list as $code => $name ) {
1090 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1091 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1096 <p
class="config-desc">
1097 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1100 <div
class="config-input">
1101 <label
class='column'>Copyright
/license
:</label
>
1104 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1105 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1107 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1108 $partner = "MediaWiki";
1109 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1110 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1111 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1112 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1114 <?php
if( $conf->License
== "cc" ) { ?
>
1116 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1117 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1118 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1119 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1125 <p
class="config-desc">
1126 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1130 <div
class="config-input">
1131 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1133 <div
class="config-input">
1134 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1136 <div
class="config-input">
1137 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1139 <p
class="config-desc">
1140 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1141 A
new account will be added only when creating a
new wiki database
.
1143 The password cannot be the same
as the username
.
1146 <div
class="config-input">
1147 <label
class='column'>Shared memory caching
:</label
>
1150 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1152 if ( $conf->turck
) {
1154 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1157 if( $conf->xcache
) {
1159 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1164 aField( $conf, "Shm", "APC", "radio", "apc" );
1167 if ( $conf->eaccel
) {
1169 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1173 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1175 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1177 <p
class="config-desc">
1178 An
object caching system such
as memcached will provide a significant performance boost
,
1179 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1181 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1182 these should not be used
if the wiki will be running on multiple application servers
.
1186 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1188 <div
class="config-section">
1189 <div
class="config-input">
1190 <label
class='column'>E
-mail
features (global):</label
>
1192 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1193 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1196 <p
class="config-desc">
1197 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1198 if sending mail doesn
't work on your server.
1201 <div class="config-input">
1202 <label class='column
'>User-to-user e-mail:</label>
1204 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1205 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1208 <p class="config-desc">
1209 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.
1211 <div class="config-input">
1212 <label class='column
'>E-mail notification about changes:</label>
1214 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1215 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1216 <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>
1219 <div class="config-desc">
1221 For this feature to work, an e-mail address must be present for the user account, and the notification
1222 options in the user's preferences must be enabled
. Also note the
1223 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1225 <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
>
1228 <div
class="config-input">
1229 <label
class='column'>E
-mail address authentication
:</label
>
1231 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1232 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1235 <div
class="config-desc">
1236 <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
1237 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1242 <h2
>Database config
</h2
>
1244 <div
class="config-section">
1245 <div
class="config-input">
1246 <label
class='column'>Database type
:</label
>
1247 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1248 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1251 <div
class="config-input" style
="clear:left"><?php
1252 aField( $conf, "DBserver", "Database host:" );
1254 <p
class="config-desc">
1255 If your database server isn
't on your web server, enter the name or IP address here.
1258 <div class="config-input"><?php
1259 aField( $conf, "DBname", "Database name:" );
1261 <div class="config-input"><?php
1262 aField( $conf, "DBuser", "DB username:" );
1264 <div class="config-input"><?php
1265 aField( $conf, "DBpassword", "DB password:", "password" );
1267 <div class="config-input"><?php
1268 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1270 <p class="config-desc">
1271 If you only have a single user account and database available,
1272 enter those here. If you have database root access (see below)
1273 you can specify new accounts/databases to be created. This account
1274 will not be created if it pre-exists. If this is the case, ensure that it
1275 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1278 <div class="config-input">
1279 <label class="column">Superuser account:</label>
1280 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1281 <label for="useroot">Use superuser account</label>
1283 <div class="config-input">
1285 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1288 <div class="config-input">
1290 aField( $conf, "RootPW", "Superuser password:", "password" );
1294 <p class="config-desc">
1295 If the database user specified above does not exist, or does not have access to create
1296 the database (if needed) or tables within it, please check the box and provide details
1297 of a superuser account, such as <strong>root</strong>, which does.
1300 <?php database_switcher('mysql
'); ?>
1301 <div class="config-input"><?php
1302 aField( $conf, "DBprefix", "Database table prefix:" );
1304 <div class="config-desc">
1305 <p>If you need to share one database between multiple wikis, or
1306 between MediaWiki and another web application, you may choose to
1307 add a prefix to all the table names to avoid conflicts.</p>
1309 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1312 <div class="config-input"><label class="column">Database charset</label>
1313 <div>Select one:</div>
1315 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1316 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1317 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1320 <p class="config-desc">
1321 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1322 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1323 cause things to break. <b>If upgrading an older installation, leave
1324 in backwards-compatible mode.</b>
1328 <?php database_switcher('postgres
'); ?>
1329 <div class="config-input"><?php
1330 aField( $conf, "DBport", "Database port:" );
1332 <div class="config-input"><?php
1333 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1335 <div class="config-input"><?php
1336 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1338 <div class="config-desc">
1339 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1340 so it is recommended that you create a new user. The above schemas are generally correct:
1341 only change them if you are sure you need to.</p>
1345 <div class="config-input" style="padding:2em 0 3em">
1346 <label class='column
'> </label>
1347 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1352 <script type="text/javascript">
1353 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1355 ## If they passed in a root user name, don't populate it on page load
1356 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1365 /* -------------------------------------------------------------------------------------- */
1366 function writeSuccessMessage() {
1367 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1369 <p>Installation successful!</p>
1370 <p>To complete the installation, please do the following:
1372 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1373 <li>Upload it to the parent directory</li>
1374 <li>Delete config/LocalSettings.php</li>
1375 <li>Start using <a href='../index.php'>your wiki</a>!
1377 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1378 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1379 which means that anyone on the same server can read your database password! Downloading
1380 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1385 <span class="success-message">Installation successful!</span>
1386 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1387 <a href="../index.php"> this link</a> to your wiki.</p>
1388 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1389 prevent other users on the server reading passwords and altering configuration data.</p>
1395 function escapePhpString( $string ) {
1396 return strtr( $string,
1407 function writeLocalSettings( $conf ) {
1408 $conf->PasswordSender
= $conf->EmergencyContact
;
1409 $magic = ($conf->ImageMagick ?
"" : "# ");
1410 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1411 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1412 $hashedUploads = $conf->safeMode ?
'' : '# ';
1414 switch ( $conf->Shm
) {
1416 $cacheType = 'CACHE_MEMCACHED';
1417 $mcservers = var_export( $conf->MCServerArray
, true );
1423 $cacheType = 'CACHE_ACCEL';
1424 $mcservers = 'array()';
1427 $cacheType = 'CACHE_NONE';
1428 $mcservers = 'array()';
1431 if ( $conf->Email
== 'email_enabled' ) {
1432 $enableemail = 'true';
1433 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1434 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1435 switch ( $conf->Enotif
) {
1436 case 'enotif_usertalk':
1437 $enotifusertalk = 'true';
1438 $enotifwatchlist = 'false';
1440 case 'enotif_allpages':
1441 $enotifusertalk = 'true';
1442 $enotifwatchlist = 'true';
1445 $enotifusertalk = 'false';
1446 $enotifwatchlist = 'false';
1449 $enableuseremail = 'false';
1450 $enableemail = 'false';
1451 $eauthent = 'false';
1452 $enotifusertalk = 'false';
1453 $enotifwatchlist = 'false';
1456 $file = @fopen
( "/dev/urandom", "r" );
1458 $secretKey = bin2hex( fread( $file, 32 ) );
1462 for ( $i=0; $i<8; $i++
) {
1463 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1465 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1468 # Add slashes to strings for double quoting
1469 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1470 if( $conf->License
== 'gfdl' ) {
1471 # Needs literal string interpolation for the current style path
1472 $slconf['RightsIcon'] = $conf->RightsIcon
;
1476 # This file was automatically generated by the MediaWiki installer.
1477 # If you make manual changes, please keep track in case you need to
1478 # recreate them later.
1480 # See includes/DefaultSettings.php for all configurable settings
1481 # and their default values, but don't forget to make changes in _this_
1484 # If you customize your file layout, set \$IP to the directory that contains
1485 # the other MediaWiki files. It will be used as a base to locate files.
1486 if( defined( 'MW_INSTALL_PATH' ) ) {
1487 \$IP = MW_INSTALL_PATH;
1489 \$IP = dirname( __FILE__ );
1492 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1493 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1495 require_once( \"includes/DefaultSettings.php\" );
1497 # If PHP's memory limit is very low, some operations may fail.
1498 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1500 if ( \$wgCommandLineMode ) {
1501 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1502 die( \"This script must be run from the command line\\n\" );
1505 ## Uncomment this to disable output compression
1506 # \$wgDisableOutputCompression = true;
1508 \$wgSitename = \"{$slconf['Sitename']}\";
1510 ## The URL base path to the directory containing the wiki;
1511 ## defaults for all runtime URL paths are based off of this.
1512 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1514 ## For more information on customizing the URLs please see:
1515 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1517 \$wgEnableEmail = $enableemail;
1518 \$wgEnableUserEmail = $enableuseremail;
1520 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1521 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1523 ## For a detailed description of the following switches see
1524 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1525 ## There are many more options for fine tuning available see
1526 ## /includes/DefaultSettings.php
1527 ## UPO means: this is also a user preference option
1528 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1529 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1530 \$wgEmailAuthentication = $eauthent;
1532 \$wgDBtype = \"{$slconf['DBtype']}\";
1533 \$wgDBserver = \"{$slconf['DBserver']}\";
1534 \$wgDBname = \"{$slconf['DBname']}\";
1535 \$wgDBuser = \"{$slconf['DBuser']}\";
1536 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1538 # MySQL specific settings
1539 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1541 # MySQL table options to use during installation or update
1542 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1544 # Experimental charset support for MySQL 4.1/5.0.
1545 \$wgDBmysql5 = {$conf->DBmysql5};
1547 # Postgres specific settings
1548 \$wgDBport = \"{$slconf['DBport']}\";
1549 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1550 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1552 ## Shared memory settings
1553 \$wgMainCacheType = $cacheType;
1554 \$wgMemCachedServers = $mcservers;
1556 ## To enable image uploads, make sure the 'images' directory
1557 ## is writable, then set this to true:
1558 \$wgEnableUploads = false;
1559 {$magic}\$wgUseImageMagick = true;
1560 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1562 ## If you want to use image uploads under safe mode,
1563 ## create the directories images/archive, images/thumb and
1564 ## images/temp, and make them all writable. Then uncomment
1565 ## this, if it's not already uncommented:
1566 {$hashedUploads}\$wgHashedUploadDirectory = false;
1568 ## If you have the appropriate support software installed
1569 ## you can enable inline LaTeX equations:
1572 \$wgLocalInterwiki = \$wgSitename;
1574 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1576 \$wgProxyKey = \"$secretKey\";
1578 ## Default skin: you can change the default skin. Use the internal symbolic
1579 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1580 \$wgDefaultSkin = 'monobook';
1582 ## For attaching licensing metadata to pages, and displaying an
1583 ## appropriate copyright notice / icon. GNU Free Documentation
1584 ## License and Creative Commons licenses are supported so far.
1585 {$rights}\$wgEnableCreativeCommonsRdf = true;
1586 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1587 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1588 \$wgRightsText = \"{$slconf['RightsText']}\";
1589 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1590 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1592 \$wgDiff3 = \"{$slconf['diff3']}\";
1594 # When you make changes to this configuration file, this will make
1595 # sure that cached pages are cleared.
1596 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1597 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1598 "; ## End of setting the $localsettings string
1600 // Keep things in Unix line endings internally;
1601 // the system will write out as local text type.
1602 return str_replace( "\r\n", "\n", $localsettings );
1605 function dieout( $text ) {
1606 die( $text . "\n\n</body>\n</html>" );
1609 function importVar( &$var, $name, $default = "" ) {
1610 if( isset( $var[$name] ) ) {
1611 $retval = $var[$name];
1612 if ( get_magic_quotes_gpc() ) {
1613 $retval = stripslashes( $retval );
1621 function importPost( $name, $default = "" ) {
1622 return importVar( $_POST, $name, $default );
1625 function importCheck( $name ) {
1626 return isset( $_POST[$name] );
1629 function importRequest( $name, $default = "" ) {
1630 return importVar( $_REQUEST, $name, $default );
1635 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1638 $xtype = "type=\"$type\"";
1644 $nolabel = ($type == "radio") ||
($type == "hidden");
1646 if ($type == 'radio')
1647 $id .= $radioCount++
;
1652 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1655 if( $type == "radio" && $value == $conf->$field ) {
1656 $checked = "checked='checked'";
1660 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1662 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1665 if( $type == "radio" ) {
1666 echo htmlspecialchars( $value );
1668 echo htmlspecialchars( $conf->$field );
1674 echo " $text</label>\n";
1678 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1681 function getLanguageList() {
1682 global $wgLanguageNames;
1683 if( !isset( $wgLanguageNames ) ) {
1684 require_once( "languages/Names.php" );
1689 $d = opendir( "../languages/messages" );
1690 /* In case we are called from the root directory */
1692 $d = opendir( "languages/messages");
1693 while( false !== ($f = readdir( $d ) ) ) {
1695 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1696 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1697 if( isset( $wgLanguageNames[$code] ) ) {
1698 $name = $code . ' - ' . $wgLanguageNames[$code];
1702 $codes[$code] = $name;
1710 #Check for location of an executable
1711 # @param string $loc single location to check
1712 # @param array $names filenames to check for.
1713 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1714 function locate_executable($loc, $names, $versioninfo = false) {
1715 if (!is_array($names))
1716 $names = array($names);
1718 foreach ($names as $name) {
1719 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1720 if (file_exists($command)) {
1724 $file = str_replace('$1', $command, $versioninfo[0]);
1725 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1732 # Test a memcached server
1733 function testMemcachedServer( $server ) {
1734 $hostport = explode(":", $server);
1737 if ( !function_exists( 'fsockopen' ) ) {
1738 $errstr = "Can't connect to memcached, fsockopen() not present";
1740 if ( !$errstr && count( $hostport ) != 2 ) {
1741 $errstr = 'Please specify host and port';
1742 var_dump( $hostport );
1745 list( $host, $port ) = $hostport;
1749 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1750 if ( $fp === false ) {
1751 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1755 $command = "version\r\n";
1756 $bytes = fwrite( $fp, $command );
1757 if ( $bytes != strlen( $command ) ) {
1758 $errstr = "Cannot write to memcached socket on $host:$port";
1762 $expected = "VERSION ";
1763 $response = fread( $fp, strlen( $expected ) );
1764 if ( $response != $expected ) {
1765 $errstr = "Didn't get correct memcached response from $host:$port";
1772 echo "<li>Connected to memcached on $host:$port successfully";
1777 function database_picker($conf) {
1780 foreach(array_keys($ourdb) as $db) {
1781 if ($ourdb[$db]['havedriver']) {
1783 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1790 function database_switcher($db) {
1792 $color = $ourdb[$db]['bgcolor'];
1793 $full = $ourdb[$db]['fullname'];
1794 print "<div id='$db' style='display:none; background: $color'>\n";
1795 print "<h3>$full specific options:</h3>\n";
1798 function printListItem( $item ) {
1799 print "<li>$item</li>";
1804 <div
class="license">
1806 <p
>This program is free software
; you can redistribute it
and/or modify
1807 it under the terms of the GNU General
Public License
as published by
1808 the Free Software Foundation
; either version
2 of the License
, or
1809 (at your option
) any later version
.</p
>
1811 <p
>This program is distributed in the hope that it will be useful
,
1812 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1813 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1814 GNU General
Public License
for more details
.</p
>
1816 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1817 along with this program
; if not
, write to the Free Software
1818 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1819 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1825 <div id
="column-one">
1826 <div
class="portlet" id
="p-logo">
1827 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1828 href
="http://www.mediawiki.org/"
1829 title
="Main Page"></a
>
1831 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1832 <div
class='portlet'><div
class='pBody'>
1834 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1835 <li
><a href
="../README">Readme
</a
></li
>
1836 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1837 <li
><a href
="../docs/">Documentation
</a
></li
>
1838 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1839 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1841 <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>