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:
- 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.
-
\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." );
-
-$memlimit = ini_get( "memory_limit" );
-$conf->raiseMemory = false;
-if( empty( $memlimit ) || $memlimit == -1 ) {
- print "
\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 );
-?>
-
-DBserver = importPost( "DBserver", "localhost" );
- $conf->DBname = importPost( "DBname", "wikidb" );
- $conf->DBuser = importPost( "DBuser", "wikiuser" );
- $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", "root" );
- $conf->RootPW = importPost( "RootPW", "" );
- $useRoot = importCheck( 'useroot', false );
- $conf->LanguageCode = importPost( "LanguageCode", "en" );
-
- ## MySQL specific:
- $conf->DBprefix = importPost( "DBprefix" );
- $conf->setSchema(
- importPost( "DBschema", "mysql4" ),
- importPost( "DBengine", "InnoDB" ) );
-
- ## Postgres specific:
- $conf->DBport = importPost( "DBport", "5432" );
- $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
- $conf->DBts2schema = importPost( "DBts2schema", "public" );
-
-/* 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( $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";
-}
-
-error_reporting( E_ALL );
-
-/**
- * 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( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
- # 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 == "gfdl" ) {
- $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
- $conf->RightsText = "GNU Free Documentation License 1.2";
- $conf->RightsCode = "gfdl";
- $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
-} elseif( $conf->License == "none" ) {
- $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
-} 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 = array_map( '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( "Errors in generated configuration; " .
- "most likely due to a bug in the installer... " .
- "Config file was: " .
- "
PHP is linked with old MySQL client libraries. If you are
- using a MySQL 4.1 server and have problems connecting to the database,
- see http://dev.mysql.com/doc/mysql/en/old-client.html for help.
\n";
- }
- $ok = true; # Let's be optimistic
-
- # Decide if we're going to use the superuser or the regular database user
- $conf->Root = $useRoot;
- if( $conf->Root ) {
- $db_user = $conf->RootUser;
- $db_pass = $conf->RootPW;
- } else {
- $db_user = $wgDBuser;
- $db_pass = $wgDBpassword;
- }
-
- # Attempt to connect
- echo( "
Attempting to connect to database server as $db_user..." );
- $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
-
- # Check the connection and respond to errors
- if( $wgDatabase->isOpen() ) {
- # Seems OK
- $ok = true;
- $wgDBadminuser = $db_user;
- $wgDBadminpassword = $db_pass;
- echo( "success.
\n" );
- $wgDatabase->ignoreErrors( true );
- $myver = $wgDatabase->getServerVersion();
- } else {
- # There were errors, report them and back out
- $ok = false;
- $errno = mysql_errno();
- $errtx = htmlspecialchars( mysql_error() );
- switch( $errno ) {
- case 1045:
- case 2000:
- echo( "failed due to authentication errors. Check passwords." );
- if( $conf->Root ) {
- # The superuser details are wrong
- $errs["RootUser"] = "Check username";
- $errs["RootPW"] = "and password";
- } else {
- # The regular user details are wrong
- $errs["DBuser"] = "Check username";
- $errs["DBpassword"] = "and password";
- }
- break;
- case 2002:
- case 2003:
- default:
- # General connection problem
- echo( "failed with error [$errno] $errtx.\n" );
- $errs["DBserver"] = "Connection failed";
- break;
- } # switch
- } #conn. att.
-
- if( !$ok ) { continue; }
-
- } else { # not mysql
- error_reporting( E_ALL );
- $wgSuperUser = '';
- ## Possible connect as a superuser
- if( $useRoot && $conf->DBtype != 'sqlite' ) {
- $wgDBsuperuser = $conf->RootUser;
- echo( "
Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
- $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
- if (!$wgDatabase->isOpen()) {
- print " error: " . $wgDatabase->lastError() . "
Warning: you requested the {$conf->DBschema} schema, " .
- "but the existing database has the $existingSchema schema. This upgrade script ".
- "can't convert it, so it will remain $existingSchema.
Warning: you requested the {$conf->DBengine} storage " .
- "engine, but the existing database uses the $existingEngine engine. This upgrade " .
- "script can't convert it, so it will remain $existingEngine.
\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 $wgDBuser exists. Skipping grants.
\n" );
- } else {
- # Yes, so run the grants
- echo( "
Granting user permissions to $wgDBuser on $wgDBname..." );
- dbsource( "../maintenance/users.sql", $wgDatabase );
- echo( "success.
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.
-
-EOT;
- } else {
- echo <<
-
-Installation successful!
-Move the config/LocalSettings.php file to the parent directory, then follow
- this link to your wiki.
-
You should change file permissions for LocalSettings.php as required to
-prevent other users on the server reading passwords and altering configuration data.