Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Configuration file.

Configuration file: Difference between revisions

From MoodleDocs
No edit summary
m (Reverted edits by Jeffbausch (talk) to last version by chris collman)
 
(16 intermediate revisions by 9 users not shown)
Line 1: Line 1:
This file is not included in the Moodle download packages. It will be created by Moodle during the installation.  
The name for Moodle's configuration file is config.php. The file is located in the moodle directory. It is not included in the Moodle download packages and is created by the installation process from the template file config-dist.php (which is included in Moodle packages).


You may need to edit the config.php file if, for example, you change you database password or change servers completely.


There are also some settings in Moodle that don't have a UI for them. Moodle download packages contain a file called config-dist.php that has examples of these special settings.
==Sample config.php file==
Although the installation process creates the config.php file for you, there may be times when you want to do this yourself. Here is a sample config.php file to work from.


'''WARNING''': You may want to edit the config.php file directly if, for example, you change you database password or change servers completely. If you do so, be very careful that there are no spaces or line breaks after the final "?>" in the file. If there are such spaces, you may get blank pages.
<pre><?php  /// Moodle Configuration File
unset($CFG);
$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle17';
$CFG->dbuser    = 'moodleuser';
$CFG->dbpass    = 'xxxxxx';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';
$CFG->wwwroot  = 'http://www.mymoodle.com/moodle';
$CFG->dirroot  = '/var/www/moodle';
$CFG->dataroot  = '/var/moodledata';
$CFG->admin    = 'admin';
$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode
$CFG->unicodedb = true;  // Database is utf8
require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?></pre>
==Enabling password salting==
See [[Password salting]].
==Including passwords in backups==
Hashed user passwords are no longer saved in backup files containing user data in Moodle 1.8.11 and 1.9.7 onwards.
If you really need passwords to be saved (in the rare case of restoring a backup with user data to a different site), the following line may be added to config.php:
$CFG->includeuserpasswordsinbackups
==Changing default block layout for new courses==
See [[Block layout]].
==Changing default theme directory location==
The location of theme directorys may be altered, using the variables ''$CFG->themewww'' and ''$CFG->themedir''. Themes from placed in the directory specified by these variables will then be available for selection using the theme selector.
For example, should you wish to place themes in a subdirectory called 'my_moodle_themes', your config.php might look like this:
<pre>
$CFG->wwwroot  = 'http://my.moodle.site.edu';
$CFG->dirroot  = '/var/www/my.moodle.site.edu/public_html';
$CFG->themewww  = $CFG->wwwroot . '/my_moodle_themes';
$CFG->themedir  = $CFG->dirroot . '/my_moodle_themes';
</pre>
==The config-dist.php file==
The config-dist.php file http://cvs.moodle.org/moodle/config-dist.php?view=markup is the template file. It contains the usual settings of a config.php file, with lots of additional settings that don't currently have a UI for them. To use these settings you have to add them to the configuration file.
==See also==
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=137889 Moodle Salting] forum discussion


[[Category: Administrator]]
[[Category: Administrator]]
[[de:Konfigurationsdatei]]
[[fr:Fichier de configuration]]
[[ja:設定ファイル]]

Latest revision as of 16:43, 13 September 2010

The name for Moodle's configuration file is config.php. The file is located in the moodle directory. It is not included in the Moodle download packages and is created by the installation process from the template file config-dist.php (which is included in Moodle packages).


Sample config.php file

Although the installation process creates the config.php file for you, there may be times when you want to do this yourself. Here is a sample config.php file to work from.

WARNING: You may want to edit the config.php file directly if, for example, you change you database password or change servers completely. If you do so, be very careful that there are no spaces or line breaks after the final "?>" in the file. If there are such spaces, you may get blank pages.

<?php  /// Moodle Configuration File 

unset($CFG);

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle17';
$CFG->dbuser    = 'moodleuser';
$CFG->dbpass    = 'xxxxxx';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

$CFG->wwwroot   = 'http://www.mymoodle.com/moodle';
$CFG->dirroot   = '/var/www/moodle';
$CFG->dataroot  = '/var/moodledata';
$CFG->admin     = 'admin';

$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode

$CFG->unicodedb = true;  // Database is utf8

require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?>

Enabling password salting

See Password salting.

Including passwords in backups

Hashed user passwords are no longer saved in backup files containing user data in Moodle 1.8.11 and 1.9.7 onwards.

If you really need passwords to be saved (in the rare case of restoring a backup with user data to a different site), the following line may be added to config.php:

$CFG->includeuserpasswordsinbackups

Changing default block layout for new courses

See Block layout.

Changing default theme directory location

The location of theme directorys may be altered, using the variables $CFG->themewww and $CFG->themedir. Themes from placed in the directory specified by these variables will then be available for selection using the theme selector.

For example, should you wish to place themes in a subdirectory called 'my_moodle_themes', your config.php might look like this:

$CFG->wwwroot   = 'http://my.moodle.site.edu';
$CFG->dirroot   = '/var/www/my.moodle.site.edu/public_html';
$CFG->themewww  = $CFG->wwwroot . '/my_moodle_themes';
$CFG->themedir  = $CFG->dirroot . '/my_moodle_themes';

The config-dist.php file

The config-dist.php file http://cvs.moodle.org/moodle/config-dist.php?view=markup is the template file. It contains the usual settings of a config.php file, with lots of additional settings that don't currently have a UI for them. To use these settings you have to add them to the configuration file.

See also