MediaWiki Installation
Setup has completed, your wiki is configured.Please delete the /config directory for extra security.
" ); } if( file_exists( "./LocalSettings.php" ) ) { writeSuccessMessage(); dieout( ); } if( !is_writable( "." ) ) { dieout( "Can't write config file, aborting
In order to configure the wiki you have to make the config subdirectory writable by the web server. Once configuration is done you'll move the created LocalSettings.php to the parent directory, and for added safety you can then remove the config subdirectory entirely.
To make the directory writable on a Unix/Linux system:
cd " . htmlspecialchars( dirname( dirname( __FILE__ ) ) ) . " chmod a+w config
Afterwards retry to start the setup.
" ); } class ConfigData { function getEncoded( $data ) { # removing latin1 support, no need... return $data; } function getSitename() { return $this->getEncoded( $this->Sitename ); } function getSysopName() { return $this->getEncoded( $this->SysopName ); } function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } function setSchema( $schema, $engine ) { $this->DBschema = $schema; if ( !preg_match( '/^\w*$/', $engine ) ){ $engine = 'InnoDB'; } switch ( $this->DBschema ) { case 'mysql5': $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8"; $this->DBmysql5 = 'true'; break; case 'mysql5-binary': $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary"; $this->DBmysql5 = 'true'; break; default: $this->DBTableOptions = "TYPE=$engine"; $this->DBmysql5 = 'false'; } $this->DBengine = $engine; # Set the global for use during install global $wgDBTableOptions; $wgDBTableOptions = $this->DBTableOptions; } } ?>- Don't forget security updates! Keep an eye on the low-traffic release announcements mailing list.
Checking environment...
Please include all of the lines below when reporting installation problems.
-
PHP " . htmlspecialchars( phpversion() ) . " installed\n";
error_reporting( 0 );
$phpdatabases = array();
foreach (array_keys($ourdb) as $db) {
$compname = $ourdb[$db]['compile'];
if( wfDl( $compname ) ) {
array_push($phpdatabases, $db);
$ourdb[$db]['havedriver'] = 1;
}
}
error_reporting( E_ALL | E_STRICT );
if (!$phpdatabases) {
print "Could not find a suitable database driver!
- For $full, compile PHP using --with-$comp, " ."or install the $comp.so module \n"; } echo '
- Found database drivers for:"; $DefaultDBtype = ''; foreach (array_keys($ourdb) AS $db) { if ($ourdb[$db]['havedriver']) { if ( $DefaultDBtype == '' ) { $DefaultDBtype = $db; } print " ".$ourdb[$db]['fullname']; } } print " \n"; if( wfIniGetBool( "register_globals" ) ) { ?>
-
Warning: PHP's register_globals option is enabled. Disable it if you can.MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
- Fatal: magic_quotes_runtime is active! This option corrupts data input unpredictably; you cannot install or use MediaWiki unless this option is disabled.
- Fatal: magic_quotes_sybase is active! This option corrupts data input unpredictably; you cannot install or use MediaWiki unless this option is disabled.
- Fatal: mbstring.func_overload is active! This option causes errors and may corrupt data unpredictably; you cannot install or use MediaWiki unless this option is disabled.
- Fatal: zend.ze1_compatibility_mode is active! This option causes horrible bugs with MediaWiki; you cannot install or use MediaWiki unless this option is disabled. safeMode = true; ?>
- Warning: PHP's safe mode is active. You may have problems caused by this, particularly if using image uploads. safeMode = false; } $sapi = htmlspecialchars( php_sapi_name() ); print "
- PHP server API is $sapi; "; $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; if( $wgUsePathInfo ) { print "ok, using pretty URLs ($script/Page_Title)"; } else { print "using ugly URLs ($script?title=Page_Title)"; } print " \n"; $conf->xml = function_exists( "utf8_encode" ); if( $conf->xml ) { print "
- Have XML / Latin1-UTF-8 conversion support. \n"; } else { dieout( "PHP's XML module is missing; the wiki requires functions in this module and won't work in this configuration. If you're running Mandrake, install the php-xml package." ); } # Check for session support if( !function_exists( 'session_name' ) ) dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." ); # session.save_path doesn't *have* to be set, but if it is, and it's # not valid/writable/etc. then it can cause problems $sessionSavePath = mw_get_session_save_path(); $ssp = htmlspecialchars( $sessionSavePath ); # Warn the user if it's not set, but let them proceed if( !$sessionSavePath ) { print "
- Warning: A value for session.save_path has not been set in PHP.ini. If the default value causes problems with saving session data, set it to a valid path which is read/write/execute for the user your web server is running under. "; } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) { # All good? Let the user know print "
- Session save path ({$ssp}) appears to be valid. "; } else { # Something not right? Warn the user, but let them proceed print "
- Warning: Your session.save_path value ({$ssp}) appears to be invalid or is not writable. PHP needs to be able to save data to this location for correct session operation. "; } # Check for PCRE support if( !function_exists( 'preg_match' ) ) dieout( "The PCRE support module appears to be missing. MediaWiki requires the Perl-compatible regular expression functions." ); # The installer can take a while, and we really don't want it to time out wfSuppressWarnings(); set_time_limit( 0 ); wfRestoreWarnings(); $memlimit = ini_get( "memory_limit" ); if( $memlimit == -1 ) { print "
- PHP is configured with no memory_limit. \n"; } else { print "
- PHP's memory_limit is " . htmlspecialchars( $memlimit ). " bytes. "; $newlimit = wfMemoryLimit(); $memlimit = wfShorthandToInteger( $memlimit ); if( $newlimit < $memlimit ) { print "Failed raising limit, installation may fail."; } elseif ( $newlimit > $memlimit ) { print "Raised memory_limit to " . htmlspecialchars( $newlimit ) . " bytes. "; } print " \n"; } $conf->xcache = function_exists( 'xcache_get' ); if( $conf->xcache ) print "
- XCache installed \n"; $conf->apc = function_exists('apc_fetch'); if ($conf->apc ) { print "
- APC installed \n"; } $conf->eaccel = function_exists( 'eaccelerator_get' ); if ( $conf->eaccel ) { print "
- eAccelerator installed \n"; } $conf->dba = function_exists( 'dba_open' ); if( !( $conf->eaccel || $conf->apc || $conf->xcache ) ) { echo( '
- Couldn\'t find eAccelerator, APC or XCache; cannot use these for object caching. ' ); } $conf->diff3 = false; $diff3locations = array_merge( array( "/usr/bin", "/usr/local/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin" ), explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); $diff3names = array( "gdiff3", "diff3", "diff3.exe" ); $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); foreach ($diff3locations as $loc) { $exe = locate_executable($loc, $diff3names, $diff3versioninfo); if ($exe !== false) { $conf->diff3 = $exe; break; } } if ($conf->diff3) print "
- Found GNU diff3: $conf->diff3. "; else print "
- GNU diff3 not found. "; $conf->ImageMagick = false; $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); foreach( $imcheck as $dir ) { $im = "$dir/convert"; if( @file_exists( $im ) ) { print "
- Found ImageMagick: $im; image thumbnailing will be enabled if you enable uploads. \n"; $conf->ImageMagick = $im; break; } } $conf->HaveGD = function_exists( "imagejpeg" ); if( $conf->HaveGD ) { print "
- Found GD graphics library built-in"; if( !$conf->ImageMagick ) { print ", image thumbnailing will be enabled if you enable uploads"; } print ". \n"; } else { if( !$conf->ImageMagick ) { print "
- Couldn't find GD library or ImageMagick; image thumbnailing disabled. \n"; } } $conf->IP = dirname( dirname( __FILE__ ) ); print "
- Installation directory: " . htmlspecialchars( $conf->IP ) . " \n"; // PHP_SELF isn't available sometimes, such as when PHP is CGI but // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME // to get the path to the current script... hopefully it's reliable. SIGH $path = ($_SERVER["PHP_SELF"] === '') ? $_SERVER["SCRIPT_NAME"] : $_SERVER["PHP_SELF"]; $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path ); print "
- Script URI path: " . htmlspecialchars( $conf->ScriptPath ) . " \n"; // We may be installing from *.php5 extension file, if so, print message $conf->ScriptExtension = '.php'; if (defined('MW_INSTALL_PHP5_EXT')) { $conf->ScriptExtension = '.php5'; print "
- Installing MediaWiki with php5 file extensions \n"; } else { print "
- Installing MediaWiki with php file extensions \n"; } print "
- Environment checked. You can install MediaWiki. \n"; $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST"); $conf->Sitename = ucfirst( importPost( "Sitename", "" ) ); $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] ) ? 'root@localhost' : $_SERVER["SERVER_ADMIN"]; $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); if ( !isset( $ourdb[$conf->DBtype] ) ) { $conf->DBtype = $DefaultDBtype; } $conf->DBserver = importPost( "DBserver", $wgDBserver ); $conf->DBname = importPost( "DBname", $wgDBname ); $conf->DBuser = importPost( "DBuser", $wgDBuser ); $conf->DBpassword = importPost( "DBpassword" ); $conf->DBpassword2 = importPost( "DBpassword2" ); $conf->SysopName = importPost( "SysopName", "WikiSysop" ); $conf->SysopPass = importPost( "SysopPass" ); $conf->SysopPass2 = importPost( "SysopPass2" ); $conf->RootUser = importPost( "RootUser" ); $conf->RootPW = importPost( "RootPW", "" ); $useRoot = importCheck( 'useroot', false ); $conf->LanguageCode = importPost( "LanguageCode", "en" ); ## MySQL specific: $conf->DBprefix = importPost( "DBprefix" ); $conf->setSchema( importPost( "DBschema", "mysql5-binary" ), importPost( "DBengine", "InnoDB" ) ); ## Postgres specific: $conf->DBport = importPost( "DBport", $wgDBport ); $conf->DBts2schema = importPost( "DBts2schema", "public" ); $conf->DBpgschema = importPost( "DBpgschema", "mediawiki" ); ## SQLite specific $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" ); ## DB2 specific: $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); $conf->DBdb2schema = importPost( "DBdb2schema", "mediawiki" ); // Oracle specific $conf->DBprefix_ora = importPost( "DBprefix_ora" ); $conf->DBdefTS_ora = importPost( "DBdefTS_ora", "USERS" ); $conf->DBtempTS_ora = importPost( "DBtempTS_ora", "TEMP" ); $conf->ShellLocale = getShellLocale( $conf->LanguageCode ); /* Check for validity */ $errs = array(); if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) { $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\""; } if( !$ourdb[$conf->DBtype]['serverless'] ) { if( $conf->DBuser == "" ) { $errs["DBuser"] = "Must not be blank"; } if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) { $errs["DBuser"] = "Username too long"; } if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) { $errs["DBpassword"] = "Must not be blank"; } if( $conf->DBpassword != $conf->DBpassword2 ) { $errs["DBpassword2"] = "Passwords don't match!"; } } if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { $errs["DBprefix"] = "Invalid table prefix"; } else { untaint( $conf->DBprefix, TC_MYSQL ); } if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora ) ) { $errs["DBprefix_ora"] = "Invalid table prefix"; } error_reporting( E_ALL | E_STRICT ); /** * Initialise $wgLang and $wgContLang to something so we can * call case-folding methods. Per Brion, this is English for * now, although we could be clever and initialise to the * user-selected language. */ $wgContLang = Language::factory( 'en' ); $wgLang = $wgContLang; /** * We're messing about with users, so we need a stub * authentication plugin... */ $wgAuth = new AuthPlugin(); /** * Validate the initial administrator account; username, * password checks, etc. */ if( $conf->SysopName ) { # Check that the user can be created $u = User::newFromName( $conf->SysopName ); if( $u instanceof User ) { # Various password checks if( $conf->SysopPass != '' ) { if( $conf->SysopPass == $conf->SysopPass2 ) { if( !$u->isValidPassword( $conf->SysopPass ) ) { $errs['SysopPass'] = "Bad password"; } } else { $errs['SysopPass2'] = "Passwords don't match"; } } else { $errs['SysopPass'] = "Cannot be blank"; } unset( $u ); } else { $errs['SysopName'] = "Bad username"; } } $conf->License = importRequest( "License", "none" ); if( $conf->License == "gfdl1_2" ) { $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt"; $conf->RightsText = "GNU Free Documentation License 1.2"; $conf->RightsCode = "gfdl1_2"; $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; } elseif( $conf->License == "gfdl1_3" ) { $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html"; $conf->RightsText = "GNU Free Documentation License 1.3"; $conf->RightsCode = "gfdl1_3"; $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; } elseif( $conf->License == "none" ) { $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = ""; } elseif( $conf->License == "pd" ) { $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/"; $conf->RightsText = "Public Domain"; $conf->RightsCode = "pd"; $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png'; } else { $conf->RightsUrl = importRequest( "RightsUrl", "" ); $conf->RightsText = importRequest( "RightsText", "" ); $conf->RightsCode = importRequest( "RightsCode", "" ); $conf->RightsIcon = importRequest( "RightsIcon", "" ); } $conf->Shm = importRequest( "Shm", "none" ); $conf->MCServers = importRequest( "MCServers" ); /* Test memcached servers */ if ( $conf->Shm == 'memcached' && $conf->MCServers ) { $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) ); foreach ( $conf->MCServerArray as $server ) { $error = testMemcachedServer( $server ); if ( $error ) { $errs["MCServers"] = $error; break; } } } else if ( $conf->Shm == 'memcached' ) { $errs["MCServers"] = "Please specify at least one server if you wish to use memcached"; } /* default values for installation */ $conf->Email = importRequest("Email", "email_enabled"); $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled"); $conf->Enotif = importRequest("Enotif", "enotif_allpages"); $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled"); if( $conf->posted && ( 0 == count( $errs ) ) ) { do { /* So we can 'continue' to end prematurely */ $conf->Root = ($conf->RootPW != ""); /* Load up the settings and get installin' */ $local = writeLocalSettings( $conf ); echo "
- \n";
echo "
Generating configuration file...
\n"; echo " \n";
$wgCommandLineMode = false;
chdir( ".." );
$ok = eval( $local );
if( $ok === false ) {
dieout( "
- ";
foreach (array_keys($ourdb) AS $db) {
$comp = $ourdb[$db]['compile'];
$full = $ourdb[$db]['fullname'];
print "
Errors in generated configuration; " . "most likely due to a bug in the installer... " . "Config file was:
" . "" . htmlspecialchars( $local ) . "" ); } $conf->DBtypename = ''; foreach (array_keys($ourdb) as $db) { if ($conf->DBtype === $db) $conf->DBtypename = $ourdb[$db]['fullname']; } if ( ! strlen($conf->DBtype)) { $errs["DBpicktype"] = "Please choose a database type"; continue; } if (! $conf->DBtypename) { $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; continue; } print "
- {$databaseSafe} is not a valid database name.
- Error selecting database {$databaseSafe}: {$err} "; print htmlspecialchars( mysql_error() ) . "
\n"; chdir( ".." ); flush(); $updater = DatabaseUpdater::newForDb( $wgDatabase, false ); $updater->doUpdates(); foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) { call_user_func_array( array( new $maint, 'execute' ), array() ); } chdir( "config" ); print "\n"; print "
- Finished update checks. \n"; // if tables don't yet exist } else { # Determine available storage engines if possible if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) { $res = $wgDatabase->query( 'SHOW ENGINES' ); $found = false; foreach ( $res as $row ) { if ( $row->Engine == $conf->DBengine && ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) ) { $found = true; break; } } if ( !$found && $conf->DBengine != 'MyISAM' ) { echo "
- Warning: " . htmlspecialchars( $conf->DBengine ) . " storage engine not available, " . "using MyISAM instead \n"; $conf->setSchema( $conf->DBschema, 'MyISAM' ); } } print "
- Creating tables..."; if ($conf->DBtype == 'mysql') { $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" ); if ($res === true) { print " done. \n
- Populating interwiki table... \n"; $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" ); } if ($res === true) { print " done. \n"; } else { print " FAILED\n"; dieout( htmlspecialchars( $res ) ); } } elseif (is_callable(array($wgDatabase, 'setup_database'))) { $wgDatabase->setup_database(); } else { $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'"; continue; } if ( $conf->DBtype == 'ibm_db2' ) { // Now that table creation is done, make sure everything is committed // Do this before doing inserts through API if ($wgDatabase->lastError()) { print "
- Errors encountered during table creation -- rolled back \n"; $wgDatabase->rollback(); } else { print "
- MediaWiki tables successfully created \n"; $wgDatabase->commit(); } } elseif ( $conf->DBtype == 'sqlite' ) { // Ensure proper searchindex format. We have to do that separately because // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid. sqlite_setup_searchindex(); } print "
- Initializing statistics... \n"; $wgDatabase->insert( 'site_stats', array ( 'ss_row_id' => 1, 'ss_total_views' => 0, 'ss_total_edits' => 1, # Main page first edit 'ss_good_articles' => 0, # Main page is not a good article - no internal link 'ss_total_pages' => 1, # Main page 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created 'ss_images' => 0 ) ); # Set up the "regular user" account *if we can, and if we need to* if( $conf->Root and $conf->DBtype == 'mysql') { # See if we need to $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); if( $wgDatabase2->isOpen() ) { # Nope, just close the test connection and continue $wgDatabase2->close(); echo( "
- User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants. \n" ); } else { # Yes, so run the grants echo( "
- " . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); $res = $wgDatabase->sourceFile( "../maintenance/users.sql" ); if ( $res === true ) { echo( " success. \n" ); } else { echo( " FAILED.\n" ); dieout( $res ); } } } if( $conf->SysopName ) { $u = User::newFromName( $conf->getSysopName() ); if ( !$u ) { print "
- Warning: Skipped sysop account creation - invalid username! \n"; } else if ( 0 == $u->idForName() ) { $u->addToDatabase(); $u->setPassword( $conf->getSysopPass() ); $u->saveSettings(); $u->addGroup( "sysop" ); $u->addGroup( "bureaucrat" ); print "
- Created sysop account " . htmlspecialchars( $conf->SysopName ) . ". \n"; } else { print "
- Could not create user - already exists! \n"; } } else { print "
- Skipped sysop account creation, no name given. \n"; } $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); $article = new Article( $titleobj ); $newid = $article->insertOn( $wgDatabase ); $revision = new Revision( array( 'page' => $newid, 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ), 'comment' => '', 'user' => 0, 'user_text' => 'MediaWiki default', ) ); $revid = $revision->insertOn( $wgDatabase ); $article->updateRevisionOn( $wgDatabase, $revision ); } /* Write out the config file now that all is well */ print "
- \n";
print "
Creating LocalSettings.php...
\n\n"; $localSettings = "<" . "?php$endl$local"; // Fix up a common line-ending problem (due to CVS on Windows) $localSettings = str_replace( "\r\n", "\n", $localSettings ); $f = fopen( "LocalSettings.php", 'xt' ); if( !$f ) { print( " \n" );
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...
\n" . "Here's the file that would have been written, try to paste it into place manually:
\n" . "\n" . htmlspecialchars( $localSettings ) . "\n" ); } if(fwrite( $f, $localSettings ) ) { fclose( $f ); print "
\n"; writeSuccessMessage(); print "\n"; } else { fclose( $f ); dieout( "
An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.
\n" ); } } while( false ); } print "\n"; $mainListOpened = false; if( count( $errs ) ) { /* Display options form */ if( $conf->posted ) { echo "Something's not quite right yet; make sure everything below is filled out correctly.
\n"; } ?>Installation successful!
To complete the installation, please do the following:
- Download config/LocalSettings.php with your FTP client or file manager
- Upload it to the parent directory
- Delete config/LocalSettings.php
- Start using your wiki!
If you are in a shared hosting environment, do not just move LocalSettings.php remotely. LocalSettings.php is currently owned by the user your webserver is running under, which means that anyone on the same server can read your database password! Downloading it and uploading it again will hopefully change the ownership to a user ID specific to you.
this link to your wiki.
Move the config/LocalSettings.php file to the parent directory, then followYou should change file permissions for LocalSettings.php as required to prevent other users on the server reading passwords and altering configuration data.