From: moodler Date: Tue, 17 Aug 2004 13:51:41 +0000 (+0000) Subject: Improvements to installation procedure. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8d783716f927e216897c98d33bcfba4f8c6d5a82;p=moodle.git Improvements to installation procedure. It now does a compatibility check of the environment as well, including memory limits and so on - so this should reduce some of the FAQs. The text is still rough ... don't translate it just yet. --- diff --git a/install.php b/install.php index 2e1c16735e..f23c39e428 100644 --- a/install.php +++ b/install.php @@ -11,7 +11,8 @@ if (file_exists('./config.php')) { ///==========================================================================// /// We are doing this in stages -/// 1. Welcome and language settings +/// 0. Welcome and language settings +/// 1. Compatibility /// 2. Database settings /// 3. Host settings /// 4. Administration directory name @@ -20,6 +21,7 @@ if (file_exists('./config.php')) { ///==========================================================================// + /// Begin the session as we are holding all information in a session /// variable until the end. @@ -32,7 +34,10 @@ if (! isset($_SESSION['INSTALL'])) { $INSTALL = &$_SESSION['INSTALL']; // Makes it easier to reference -if ( empty($INSTALL['language']) and empty($_POST['language']) ) { // First time through this script + +/// If it's our first time through this script then we need to set some default values + +if ( empty($INSTALL['language']) and empty($_POST['language']) ) { /// set defaults $INSTALL['language'] = 'en'; @@ -50,7 +55,7 @@ if ( empty($INSTALL['language']) and empty($_POST['language']) ) { // First ti $INSTALL['admindirname'] = 'admin'; - $INSTALL['stage'] = 1; + $INSTALL['stage'] = 0; } @@ -58,12 +63,15 @@ if ( empty($INSTALL['language']) and empty($_POST['language']) ) { // First ti //==========================================================================// /// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php + $SESSION->lang = (!empty($_POST['language'])) ? $_POST['language'] : $INSTALL['language']; $CFG->dirroot = $INSTALL['dirroot']; $CFG->dataroot = $INSTALL['dataroot']; $CFG->directorypermissions = 0777; +/// Include some moodle libraries + require_once('./lib/moodlelib.php'); require_once('./lib/weblib.php'); require_once('./lib/adodb/adodb.inc.php'); @@ -74,18 +82,32 @@ if ($INSTALL['wwwroot'] == '') { list($INSTALL['wwwroot'], $xtra) = explode('/install.php', qualified_me()); } -$stagetext = array(1 => get_string('chooselanguage', 'install'), - get_string('directorysettings', 'install'), - get_string('databasesettings', 'install'), - get_string('admindirsetting', 'install'), - get_string('configurationcomplete', 'install') +$stagetext = array(0 => get_string('chooselanguage', 'install'), + get_string('compatibilitysettings', 'install'), + get_string('directorysettings', 'install'), + get_string('databasesettings', 'install'), + get_string('admindirsetting', 'install'), + get_string('configurationcomplete', 'install') ); + + +//==========================================================================// + +/// Are we in help mode? + +if (isset($_GET['help'])) { + $nextstage = -1; +} + + + //==========================================================================// /// Was data submitted? -if (!empty($_POST['stage'])) { + +if (isset($_POST['stage'])) { /// Get the stage for which the form was set and the next stage we are going to @@ -96,7 +118,7 @@ if (!empty($_POST['stage'])) { $nextstage = $_POST['stage'] - 1; } - if ($nextstage < 1) $nextstage = 1; + if ($nextstage < 0) $nextstage = 0; /// Store any posted data @@ -107,7 +129,7 @@ if (!empty($_POST['stage'])) { } else { $goforward = true; - $nextstage = 1; + $nextstage = 0; } @@ -116,6 +138,7 @@ if (!empty($_POST['stage'])) { //==========================================================================// /// Check the directory settings + if ($INSTALL['stage'] == 2) { error_reporting(0); @@ -156,15 +179,20 @@ if ($INSTALL['stage'] == 2) { /// Check database settings if stage 3 data submitted /// Try to connect to the database. If that fails then try to create the database + if ($INSTALL['stage'] == 3) { if (empty($INSTALL['dbname'])) { $INSTALL['dbname'] = 'moodle'; } - /// different format for postgres7 - if ($INSTALL['dbtype'] == 'postgres7') { + /// different format for postgres7 by socket + if ($INSTALL['dbtype'] == 'postgres7' and ($INSTALL['dbhost'] == 'localhost' || $INSTALL['dbhost'] == '127.0.0.1')) { $INSTALL['dbhost'] = "user='{$INSTALL['dbuser']}' password='{$INSTALL['dbpass']}' dbname='{$INSTALL['dbname']}'"; + $INSTALL['dbuser'] = ''; + $INSTALL['dbpass'] = ''; + $INSTALL['dbname'] = ''; + if ($INSTALL['prefix'] == '') { /// must have a prefix $INSTALL['prefix'] = 'mdl_'; } @@ -227,6 +255,7 @@ if ($nextstage == 4 or $INSTALL['stage'] == 4) { /// Display or print the data /// Put the data into a string /// Try to open config file for writing. + if ($nextstage == 5) { $str = ' -

MOODLE INSTALL

+ +
+ + + + - + + + + + + -

+

+
+ \n"; echo "
\n"; } - echo "

(Continue)

\n"; + $options = array(); + $options['lang'] = $INSTALL['language']; + print_single_button("index.php", $options, get_string('continue')." »"); } else { $formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php"; form_table($nextstage, $formaction); @@ -322,6 +373,10 @@ if ($nextstage == 5) {
+ + @@ -349,7 +404,7 @@ function print_object($object) { //==========================================================================// -function form_table($nextstage = 1, $formaction = "install.php") { +function form_table($nextstage = 0, $formaction = "install.php") { global $INSTALL; /// standard lines for all forms @@ -362,7 +417,7 @@ function form_table($nextstage = 1, $formaction = "install.php") {

@@ -372,6 +427,28 @@ function form_table($nextstage = 1, $formaction = "install.php") { @@ -458,10 +535,11 @@ function form_table($nextstage = 1, $formaction = "install.php") { - 1) ? "\n" : " \n" ?> + 0) ? "\n" : " \n" ?> +  \n"; ?> - \n" : " \n" ?> + \n" : " \n" ?> @@ -473,6 +551,83 @@ function form_table($nextstage = 1, $formaction = "install.php") { +//==========================================================================// + +function print_compatibility_row($success, $testtext, $errormessage, $helpfield='') { + echo "\n"; + echo "

$testtext

\n"; + if ($success) { + echo "

".get_string('pass', 'install')."

\n"; + echo " \n"; + } else { + echo "

".get_string('fail', 'install')."

\n"; + echo ""; + echo "

$errormessage "; + install_helpbutton("install.php?help=$helpfield"); + echo "

\n"; + } + echo "\n"; + return $success; +} + + +//==========================================================================// + +function install_helpbutton($url, $title='') { + if ($title == '') { + $title = get_string('help'); + } + echo ""; + echo "\"$title\"";"; + echo "\n"; +} + + + +//==========================================================================// + +function print_install_help($help) { + echo "

"; + switch ($help) { + case 'phpversionhelp': + print_string($help, 'install', phpversion()); + break; + case 'memorylimithelp': + print_string($help, 'install', ini_get('memory_limit')); + break; + default: + print_string($help, 'install'); + } + echo "

\n"; +} + + +//==========================================================================// + +function get_memory_limit() { + if ($limit = ini_get('memory_limit')) { + return $limit; + } else { + return get_cfg_var('memory_limit'); + } +} + +//==========================================================================// + +function check_memory_limit() { + + /// if limit is already 16M or more then we don't care if we can change it or not + if ((int)str_replace('M', '', get_memory_limit()) >= 16) { + return true; + } + + /// Otherwise, see if we can change it ourselves + @ini_set('memory_limit', '16M'); + return ((int)str_replace('M', '', get_memory_limit()) >= 16); +} + //==========================================================================// function css_styles() { @@ -481,12 +636,19 @@ function css_styles() { A very few webhosts use /admin as a special URL for you to access a + A very few webhosts use /admin as a special URL for you to access a control panel or something. Unfortunately this conflicts with the standard location for the Moodle admin pages. You can fix this by renaming the admin directory in your installation, and putting that - new name here. For example:
moodleadmin
. - This will fix admin links in Moodle.

"; + new name here. For example:
 
moodleadmin
 
+ This will fix admin links in Moodle."; $string['chooselanguage'] = 'Choose a language'; +$string['compatibilitysettings'] = 'The following is a check on the compatibility of the server to run Moodle'; $string['configfilenotwritten'] = "The installer script was not able to automatically create a config.php file containing your chosen settings. Please copy the following code into a file named config.php within the root directory of Moodle."; $string['configfilewritten'] = "config.php has been successfully created"; $string['configurationcomplete'] = 'Configuration completed'; $string['database'] = 'Database'; $string['databasesettings'] = " -

Now you need to configure the database where most Moodle data + Now you need to configure the database where most Moodle data will be stored. This database must already have been created - and a username and password created to access it.

-

Type: mysql or postgres7
- Host Server: eg localhost or db.isp.com
- Name: database name, eg moodle
- User: your database username
- Password: your database password
- Tables Prefix: prefix to use for all table names

"; + and a username and password created to access it.
+
 
+ Type: mysql or postgres7
+ Host: eg localhost or db.isp.com
+ Name: database name, eg moodle
+ User: your database username
+ Password: your database password
+ Tables Prefix: prefix to use for all table names"; $string['dataroot'] = 'Data'; $string['datarooterror'] = "The 'Data' setting is incorrect"; $string['dbconnectionerror'] = 'Database connection error. Please check your database settings'; @@ -34,22 +36,49 @@ $string['dbpass'] = 'Password'; $string['dbprefix'] = 'Tables prefix'; $string['dbtype'] = 'Type'; $string['directorysettings'] = " -

WWW: + WWW: You need to tell Moodle where it is located. Specify the full web address to where moodle has been installed. If your web site is accessible via multiple URLs then choose the most natural one - that your students would use. Do not include a trailing slash

-

Directory: + that your students would use. Do not include a trailing slash
 
+ Directory: Specify the full OS directory path to this same location - Make sure the upper/lower case is correct

-

Data: + Make sure the upper/lower case is correct
 
+ Data: You need a place where Moodle can save uploaded files. This directory should be readable AND WRITEABLE by the web server user (usually 'nobody' or 'apache'), but it should not be accessible - directly via the web.

"; + directly via the web."; $string['dirroot'] = 'Directory'; $string['dirrooterror'] = "The 'Directory' setting was incorrect. Try the following setting"; +$string['fail'] = 'Fail'; +$string['fileuploads'] = 'File Uploads'; +$string['fileuploadserror'] = 'This should be on'; +$string['fileuploadshelp'] = 'Moodle requires file uploading to be switched on'; +$string['gdversion'] = 'GD version'; +$string['gdversionerror'] = 'The GD library should be present to process and create images'; +$string['gdversionhelp'] = 'The GD library should be present to process and create images'; +$string['installation'] = 'Installation'; +$string['memorylimit'] = 'Memory Limit'; +$string['memorylimiterror'] = 'The memory limit needs to be set to 16M or more or be changeable'; +$string['memorylimithelp'] = "The memory limit needs to be set to 16M or more or be changeable. Your current memory limit is set to \$a"; +$string['pass'] = 'Pass'; +$string['PHPversion'] = 'PHP version'; +$string['PHPversionerror'] = 'PHP version must be at least 4.1.0'; +$string['phpversionhelp'] = "Moodle requires a PHP version of at least 4.1.0. You are currently running version \$a"; +$string['safemode'] = 'Safe Mode'; +$string['safemodeerror'] = 'Moodle can not handle files properly with safe mode on'; +$string['safemodehelp'] = 'Moodle can not handle files properly with safe mode on'; +$string['sessionautostart'] = 'Session Auto Start'; +$string['sessionautostarterror'] = 'This should be off'; +$string['sessionautostarthelp'] = 'Session auto start should be turned off'; +$string['sessionsavepath'] = 'Session Save Path'; +$string['sessionsavepatherror'] = 'It seems your server does not support sessions'; +$string['sessionsavepathhelp'] = 'Moodle requires session support'; +$string['magicquotesruntime'] = 'Magic Quotes Run Time'; +$string['magicquotesruntimeerror'] = 'This should be off'; +$string['magicquotesruntimehelp'] = 'Magic quotes should be turned off'; $string['wwwroot'] = 'WWW'; $string['wwwrooterror'] = "The 'WWW' setting is incorrect"; diff --git a/pix/moodlelogo-med.gif b/pix/moodlelogo-med.gif new file mode 100755 index 0000000000..6113a983e0 Binary files /dev/null and b/pix/moodlelogo-med.gif differ