2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 header( "Content-type: text/html; charset=utf-8" );
23 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
24 "http://www.w3.org/TR/html4/loose.dtd">
27 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
28 <meta name
="robots" content
="noindex,nofollow">
29 <title
>MediaWiki installation
</title
>
30 <style type
="text/css">
35 background
-color
: #eee;
37 border
: solid
1px
#444;
57 /* margin-right: 200px; */
70 <a href
="http://www.mediawiki.org/"><img
71 src
="../images/wiki.png" width
="135" height
="135" alt
="" border
="0" /></a
>
74 <b
><a href
="http://www.mediawiki.org/">MediaWiki
</a
></b
> is
75 Copyright (C
) 2001-2004 by Magnus Manske
, Brion Vibber
, Lee Daniel Crocker
,
76 Tim Starling
, Erik M
ö
;ller
, and others
.</p
>
79 <li
><a href
="../README">Readme
</a
></li
>
80 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
81 <li
><a href
="../docs/">doc
/</a
></li
>
82 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
85 <p>This program is free software; you can redistribute it and/or modify
86 it under the terms of the GNU General Public License as published by
87 the Free Software Foundation; either version 2 of the License, or
88 (at your option) any later version.</p>
90 <p>This progarm is distributed in the hope that it will be useful,
91 but WITHOUT ANY WARRANTY; without even the implied warranty of
92 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93 GNU General Public License for more details.</p>
95 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
96 along with this program; if not, write to the Free Software
97 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
98 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
102 include( "../includes/DefaultSettings.php" );
105 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
110 /* Check for existing configurations and bug out! */
112 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
113 dieout( "<h2>Wiki is configured.</h2>
115 <p>Already configured... <a href='../index
.php
'>return to the wiki</a>.</p>
117 <p>(You should probably remove this directory for added security.)</p>" );
120 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
121 dieout( "<h2>You're configured
!</h2
>
123 <p
>Please move
<tt
>LocalSettings
.php
</tt
> to the parent directory
, then
124 <a href
='../index.php'>try out your wiki
</a
>.
125 (You should remove this config directory
for added security once you
're done.)</p>" );
128 if( !is_writable( "." ) ) {
129 dieout( "<h2>Can't write config file
, aborting
</h2
>
131 <p
>In order to configure the wiki you have to make the
<tt
>config
</tt
> subdirectory
132 writable by the web server
. Once configuration is done you
'll move the created
133 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
134 then remove the <tt>config</tt> subdirectory entirely.</p>
136 <p>To make the directory writable on a Unix/Linux system:</p>
139 cd <i>/path/to/wiki</i>
145 include( "../install-utils.inc" );
146 include( "../maintenance/updaters.inc" );
148 function getEncoded( $data ) {
150 global $wgInputEncoding;
151 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
154 return utf8_decode( $data ); /* to latin1 wikis */
157 function getSitename() { return $this->getEncoded( $this->Sitename ); }
158 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
159 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
165 <h2>Checking environment...</h2>
169 $conf = new ConfigData;
171 install_version_checks();
172 print "<li>PHP " . phpversion() . " ok</li>\n";
175 $conf->zlib = function_exists( "gzencode" );
176 $z = $conf->zlib ? "Have" : "No";
177 print "<li>$z zlib support</li>\n";
179 $conf->gd = function_exists( "imagejpeg" );
181 print "<li>Found GD graphics library built-in</li>\n";
183 print "<li>No built-in GD library</li>\n";
186 if( file_exists( "/usr/bin/convert" ) ) {
187 $conf->ImageMagick = "/usr/bin/convert";
188 print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
189 } elseif( file_exists( "/usr/local/bin/convert" ) ) {
190 $conf->ImageMagick = "/usr/local/bin/convert";
191 print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
193 $conf->ImageMagick = false;
194 print "<li>No ImageMagick.</li>\n";
198 # $conf->IP = "/Users/brion/Sites/inplace";
200 $conf->IP = getcwd();
202 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
204 # $conf->ScriptPath = "/~brion/inplace";
205 $conf->ScriptPath = preg_replace( '{^
(.*)/config
.*$
}', '$1', $_SERVER["REQUEST_URI"] );
206 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
208 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
210 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
211 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
212 $conf->DBserver = importPost( "DBserver", "localhost" );
213 $conf->DBname = importPost( "DBname", "wikidb" );
214 $conf->DBuser = importPost( "DBuser", "wikiuser" );
215 $conf->DBpassword = importPost( "DBpassword" );
216 $conf->DBpassword2 = importPost( "DBpassword2" );
217 $conf->RootPW = importPost( "RootPW" );
218 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
219 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
220 $conf->SysopPass = importPost( "SysopPass" );
221 $conf->SysopPass2 = importPost( "SysopPass2" );
223 /* Check for validity */
226 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
227 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
229 if( $conf->DBpassword == "" ) {
230 $errs["DBpassword"] = "Must not be blank";
232 if( $conf->DBpassword != $conf->DBpassword2 ) {
233 $errs["DBpassword2"] = "Passwords don't match
!";
236 if( $conf->SysopPass == "" ) {
237 $errs["SysopPass
"] = "Must not be blank
";
239 if( $conf->SysopPass != $conf->SysopPass2 ) {
240 $errs["SysopPass2
"] = "Passwords don
't match!";
243 if( $conf->posted && ( 0 == count( $errs ) ) ) {
244 do { /* So we can 'continue' to end prematurely */
245 $conf->Root = ($conf->RootPW != "");
247 /* Load up the settings and get installin' */
248 $local = writeLocalSettings( $conf );
249 $wgCommandLineMode = false;
252 $wgDBadminuser = $wgDBuser;
253 $wgDBadminpassword = $wgDBpassword;
254 $wgCommandLineMode = true;
255 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
256 include_once( "Setup.php" );
257 include_once( "../maintenance/InitialiseMessages.inc" );
259 $wgTitle = Title
::newFromText( "Installation script" );
262 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
264 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
266 $wgDatabase->mIgnoreErrors
= true;
268 if ( !$wgDatabase->isOpen() ) {
269 $errs["DBserver"] = "Couldn't connect to database";
273 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
275 print "<li>MySQL error " . ($err = mysql_errno() ) .
276 ": " . htmlspecialchars( mysql_error() );
280 $errs["RootPW"] = "Check password";
282 $errs["DBuser"] = "Check name/pass";
283 $errs["DBpassword"] = "or enter root";
284 $errs["DBpassword2"] = "password below";
285 $errs["RootPW"] = "Got root?";
290 $errs["DBserver"] = "Connection failed";
293 $errs["DBserver"] = "Couldn't connect to database";
297 print "<li>Connected to database... $myver";
298 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
299 print "; enabling MySQL 4 enhancements";
300 $conf->DBmysql4
= true;
301 $local = writeLocalSettings( $conf );
305 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
307 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
309 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
311 print "<li>Couldn't create database <tt>" .
312 htmlspecialchars( $wgDBname ) .
313 "</tt>; try with root access or check your username/pass.</li>\n";
314 $errs["RootPW"] = "<- Enter";
317 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
320 $wgDatabase->selectDB( $wgDBname );
322 if( $wgDatabase->tableExists( "cur" ) ) {
323 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
327 do_ipblocks_update(); flush();
328 do_interwiki_update(); flush();
329 do_index_update(); flush();
330 do_linkscc_update(); flush();
331 do_hitcounter_update(); flush();
332 do_recentchanges_update(); flush();
333 initialiseMessages(); flush();
337 print "<li>Finished update checks.</li>\n";
339 # FIXME: Check for errors
340 print "<li>Creating tables...";
341 dbsource( "../maintenance/tables.sql", $wgDatabase );
342 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
343 dbsource( "../maintenance/indexes.sql", $wgDatabase );
344 print " done.</li>\n";
346 print "<li>Initializing data...";
347 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
348 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
350 if( $conf->SysopName
) {
351 $u = User
::newFromName( $conf->getSysopName() );
352 if ( 0 == $u->idForName() ) {
354 $u->setPassword( $conf->getSysopPass() );
355 $u->addRight( "sysop" );
356 $u->addRight( "developer" ); /* ?? */
358 print "<li>Created sysop account <tt>" .
359 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
361 print "<li>Could not create user - already exists!</li>\n";
364 print "<li>Skipped sysop account creation, no name given.</li>\n";
367 print "<li>Initialising log pages...";
369 "uploadlogpage" => "uploadlogpagetext",
370 "dellogpage" => "dellogpagetext",
371 "protectlogpage" => "protectlogtext",
372 "blocklogpage" => "bloglogtext"
374 $metaNamespace = Namespace::getWikipedia();
375 $now = wfTimestampNow();
376 $won = wfInvertTimestamp( $now );
377 foreach( $logs as $page => $text ) {
378 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
379 $logText = wfStrencode( wfMsgNoDB( $text ) );
380 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
381 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
382 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
386 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
387 $title = $titleobj->getDBkey();
388 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
389 "VALUES (0,'$title','" .
390 wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
391 $wgDatabase->query( $sql, $fname );
394 initialiseMessages();
398 # Grant user permissions
399 dbsource( "../maintenance/users.sql", $wgDatabase );
403 /* Write out the config file now that all is well */
404 print "<p>Creating LocalSettings.php...</p>\n\n";
405 $localSettings = "<" . "?php\n$local\n?" . ">";
406 $f = fopen( "LocalSettings.php", "xt" );
408 dieout( "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" .
409 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
410 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
412 fwrite( $f, $localSettings );
415 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
416 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
426 if( count( $errs ) ) {
427 /* Display options form */
429 if( $conf->posted
) {
430 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
434 <form name
="config" method
="post">
442 aField( $conf, "Sitename", "Site name:" );
446 Your site name should be a relatively short word
. It
'll appear as the namespace
447 name for 'meta
' pages as well as throughout the user interface. Good site names
448 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
449 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
450 which may cause problems.
455 aField( $conf, "EmergencyContact", "Contact e-mail" );
459 This will be used as the return address for password reminders and
460 may be displayed in some error conditions so visitors can get in
465 <label for="LanguageCode">Language</label>
466 <select id="LanguageCode" name="LanguageCode">
468 $list = getLanguageList();
469 foreach( $list as $code => $name ) {
470 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
471 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
477 You may select the language for the user interface of the wiki...
478 Some localizations are less complete than others. This also controls
479 the character encoding; Unicode is more flexible, but Latin-1 may be
480 more compatible with older browsers for some languages. Unicode will
481 be used where not specified otherwise.
485 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
488 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
491 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
494 A sysop user account can lock or delete pages, block problematic IP
495 addresses from editing, and other maintenance tasks. If creating a new
496 wiki database, a sysop account will be created with the given name
501 <h2>Database config</h2>
505 aField( $conf, "DBserver", "MySQL server" );
508 If your database server isn't on your web server
, enter the name
513 aField( $conf, "DBname", "Database name" );
516 aField( $conf, "DBuser", "DB username" );
519 aField( $conf, "DBpassword", "DB password", "password" );
522 aField( $conf, "DBpassword2", "again", "password" );
525 If you only have a single user account
and database available
,
526 enter those here
. If you have database root
access (see below
)
527 you can specify
new accounts
/databases to be created
.
533 aField( $conf, "RootPW", "DB root password", "password" );
537 You will only need this
if the database
and/or user account
538 above don
't already exist.
539 Do <em>not</em> type in your machine's root password
! MySQL
540 has its own
"root" user with a separate password
. (It might
541 even be blank
, depending on your configuration
.)
545 <label
> 
;</label
>
546 <input type
="submit" value
="Install!" />
556 /* -------------------------------------------------------------------------------------- */
558 function writeAdminSettings( $conf ) {
560 \$wgDBadminuser = \"{$conf->DBadminuser}\";
561 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
565 function writeLocalSettings( $conf ) {
566 $conf->DBmysql4
= $conf->DBmysql4 ?
'true' : 'false';
567 $conf->UseImageResize
= $conf->UseImageResize ?
'true' : 'false';
568 $conf->DBsqluser
= $conf->DBuser
;
569 $conf->DBsqlpassword
= $conf->DBpassword
;
570 $conf->PasswordSender
= $conf->EmergencyContact
;
571 if( $conf->LanguageCode
== "en-utf8" ) {
572 $conf->LanguageCode
= "en";
573 $conf->Encoding
= "UTF-8";
575 $sep = (DIRECTORY_SEPARATOR
== "\\") ?
";" : ":";
577 # This file was automatically generated. Don't touch unless you
578 # know what you're doing; see LocalSettings.sample for an edit-
581 \$IP = \"{$conf->IP}\";
582 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
583 include_once( \"DefaultSettings.php\" );
585 if( \$wgCommandLineMode ) {
586 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
589 \$wgSitename = \"{$conf->Sitename}\";
591 \$wgScriptPath = \"{$conf->ScriptPath}\";
592 \$wgScript = \"\$wgScriptPath/index.php\";
593 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
595 \$wgArticlePath = \"\$wgScript?title=\$1\";
596 # \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it
598 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
599 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
601 \$wgUploadPath = \"\$wgScriptPath/images\";
602 \$wgUploadDirectory = \"\$IP/images\";
603 \$wgLogo = \"\$wgUploadPath/wiki.png\";
605 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
606 \$wgPasswordSender = \"{$conf->PasswordSender}\";
608 \$wgDBserver = \"{$conf->DBserver}\";
609 \$wgDBname = \"{$conf->DBname}\";
610 \$wgDBuser = \"{$conf->DBuser}\";
611 \$wgDBpassword = \"{$conf->DBpassword}\";
612 \$wgDBsqluser = \"{$conf->DBsqluser}\";
613 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
615 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
617 \$wgUseImageResize = {$conf->UseImageResize};
619 ## If you have the appropriate support software installed
620 ## you can enable inline LaTeX equations:
622 # \$wgMathPath = \"{$wgUploadPath}/math\";
623 # \$wgMathDirectory = \"{$wgUploadDirectory}/math\";
624 # \$wgTmpDirectory = \"{$wgUploadDirectory}/tmp\";
626 \$wgLocalInterwiki = \$wgSitename;
628 \$wgLanguageCode = \"{$conf->LanguageCode}\";
629 " . ($conf->Encoding ?
"\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
634 function dieout( $text ) {
635 die( $text . "\n\n</body>\n</html>" );
638 function importPost( $name, $default = "" ) {
639 if( isset( $_POST[$name] ) ) {
640 return $_POST[$name];
646 function aField( &$conf, $field, $text, $type = "" ) {
647 if( $type != "" ) $type = "type=\"$type\"";
648 echo "\t\t<label for=\"$field\">$text</label>\n";
649 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
650 echo htmlspecialchars( $conf->$field );
654 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
657 function getLanguageList() {
658 global $wgLanguageNames;
659 if( !isset( $wgLanguageNames ) ) {
660 $wgLanguageCode = "xxx";
661 function wfLocalUrl( $x ) { return $x; }
662 function wfLocalUrlE( $x ) { return $x; }
663 include( "../languages/Language.php" );
667 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
669 $d = opendir( "../languages" );
670 while( false !== ($f = readdir( $d ) ) ) {
671 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
672 $code = strtolower( $m[1] );
673 $codes[$code] = "$code - " . $wgLanguageNames[$code];
674 if( in_array( $code, $latin1 ) ) {
675 $codes[$code] .= " - Latin-1";
679 $codes["en-utf8"] = "en - English - Unicode";