Installation FAQ

Revision as of 06:19, 22 April 2008 by Ken Wilson (talk | contribs) (I receive this error "500:Internal Server Error": Update and reformatting)

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.2. Up-to-date documentation for the latest stable version of Moodle is probably available here: Installation FAQ.


Table of Contents


PHP - is it installed and what version do I have?

Make a new file on your web site called info.php, containing the following text, and call it from your browser:

<?PHP phpinfo() ?>

If nothing happens then you don't have PHP installed or your webserver is not configured to handle .php files properly. See the installation docs for some information about where to download it for your computer. See the phpinfo page for details about the content of this page. Table of Contents

System information needed for Installation Forum

When posting questions to the installation forum, try to provide as much background information as possible about your moodle system. Use this template to copy and paste into your post:

  • Server Operating System name (version also if possible):
  • Browser name (version also if possible):
  • Moodle version:
  • Moodle install type? (New/Upgrade):
  • Moodle config.php attached?(Y/N):
  • Phpinfo attached? (Y/N):

For the last two items, try to include the following in your post as an attachment:

  • A copy of your phpinfo output as shown in your browser (see the instructions above for an explanation of how to obtain this).
  • A copy of the Moodle configuration file. This is located in the directory moodle and is named config.php

Copy and paste both of these into a single text file (using vi, Notepad, etc) and attach this to your post.

If you cannot provide your phpinfo, try to copy & paste and complete these in your post:

  • Webserver (e.g. Apache/IIS) version:
  • Database server (e.g. MySQL, PostgreSQL) version:
  • PHP version:

For installation on web hosting accounts: contact your support desk who should be able to tell you this information.

Security Warning: Make sure you edit any files and delete any passwords before posting onto the forum.

Table of Contents

What & where are Moodle's configuration settings stored?

Configuration settings are stored in the config.php file stored in your moodle folder. This file is created during the installation process. If there is a problem and the installation cannot create the file, you can try creating it manually from the Configuration file docs. Please remember that manually editing the file is not recommended and may lead to blank pages, especially if there are additional spaces and/or lines after the final php closing tag "?>".

Table of Contents

Running a health check

Moodle contains a script that will help identify common php and webserver configuration problems as well as configuration problems. It is a good idea to run this script to check if you are having post-installation problems. Use your browser to run this file:

Change the above line if you have installed moodle in the webroot instead of a folder inside the webroot.

Table of Contents

Downloading previous releases of Moodle

  • Generic Packages: If your server does not meet the requirements for the current version of Moodle, you can download previous releases by using wget, lynx or curl with this URL:[version_number] 
For example: to download Moodle version 1.5, use You'll see a directory tree with the files displayed. Click on the one you want and download as normal - if you require the latest update of the version, scroll to the end of the list and download the "moodle-latest" file, or alternatively use these URLs for zip or tgz downloads:[version_number]/moodle-latest-[version_number].zip[version_number]/moodle-latest-[version_number].tgz
Changes made in the version in the last month are listed in the "CHANGES" file in the directory listing. The files you download contain Moodle code and are not the Windows or Mac packages - so you need to have a webserver, a database server and PHP already installed. The earliest version available is Moodle 1.3.
  • Windows Packages: To download previous releases of the Moodle packages for Windows, use this URL:[version_number].zip
  • Mac Packages: To download previous releases of the Mac pacakges, use either of these URLs (depending on whether you need the Intel or PPC package):[version_number].dmg[version_number}.dmg
  • Using CVS: You can also use CVS to download older releases and incremental releases of the Moodle generic packages, e.g. Moodle 1.5.4 - see the CVS documentation.

Table of Contents

How to enable and check PHP error logs

PHP can be set up to log errors in a variety of different ways: two of these involve the use of the php.ini file and the ini_set command.

  • Using the php.ini file: The log settings are contained in the php.ini file stored on the server. If you don't know where that is, edit your Moodle config.php and add the following as the second line
then reload the web page. Look for the entry Configuration File (php.ini) Path.
When you have located php.ini open it in your favorite text editor. Find the Error handling and logging section of the php.ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log - this tells you the location of the file errors are logged to. If it is commented out then errors will be sent to the web server error log file. Remember, if you make any changes to this file you will need to restart the web server (or just reboot the server).
  • Using ini_set commands: If you are using Moodle 1.7 or higher, the previous steps are not enough. In those versions error logging parameters are dependant on certain administrative settings that you specify in the debugging section. The problem is that if you can't access the administrative pages, you can't set the debugging options. So the only way to modify them is by adding the following lines to your config.php file, just before the last line (the one containing a single'?>' only):
 ini_set ('display_errors', 'on');
 ini_set ('log_errors', 'on');
 ini_set ('display_startup_errors', 'on');
 ini_set ('error_reporting', E_ALL);
This will enable the same settings specified above even if Moodle sets them otherwise.
Important: Remember to put them just before the last line of config.php.

Table of Contents

Any text I add with an apostrophe (') or a quote (") causes errors or comes up with a slash added

Problems caused by apostrophes are caused by incorrect "magic quotes" settings. Moodle requires the following settings in the php.ini file (which are usually the default):

magic_quotes_gpc = On
magic_quotes_runtime = Off

Please see Installing Moodle for more details.

If you are using Debian then the problem might be in the version of PHP that you have installed. Have a look at this bug report to see if it matches your situation.

Email copies are not being sent from my forums

You must set up cron properly if you want Moodle to send out automatic email from forums, assignments etc. This same process also performs a number of clean-up tasks such as deleting old unconfirmed users, unenrolling old students and so on.

Basically, you need to set up a process to regularly call the script
. Please refer to the cron instructions.


  • Try the default settings in Administration > Server > Email. This generally works.
  • Make sure that allowuseremailcharset in Administration > Server > Email is set to No. Setting this to Yes can cause a problem in some versions of Moodle.

Table of Contents

Error: database connection failed

If you get errors like "database connection failed" or "could not connect to the database you specified", here are some possible reasons and some possible solutions.

  • Your database server isn't installed or running. To check this for MySQL try typing the following command line
$telnet database_host_name 3306
You should get a cryptic response which includes the version number of the MySQL server.
  • If you are attempting to run two instances of Moodle on different ports, use the ip address of the host (not localhost) in the $CFG->dbhost setting, e.g. $CFG->dbhost =
  • You don't have the PHP mysql or postgresql extensions installed (please refer to FAQ re. whether PHP is installed).
  • You haven't created a Moodle database and assigned a user with the correct privileges to access it.
  • The Moodle database settings are incorrect. The database name, database user or database user password in your Moodle configuration file config.php are incorrect. Use phpMyAdmin to set up and check your MySQL installation.
  • Check that there are no apostrophes or non-alphabetic letters in your MySQL username or password.
  • You are using MySQL version 4.1 or higher but the PHP MySQL extension is pre-4.1 (check in your phpinfo output). In this case the default password hashing algorithm is incompatible with that available in the PHP mysql extension versions 4.x.x. Use these MySQL commands to change the passwords to the old format:
mysql>SET PASSWORD FOR 'root'@'localhost' = OLD_PASSWORD('password');
mysql>SET PASSWORD FOR 'moodleuser'@'localhost' = OLD_PASSWORD('password');
Also, consider upgrading your PHP MySQL extension. See this MySQL document for further information on how to deal with this problem.
  • You are using Fedora core 3 or some other Linux system with SELinux installed and enabled. See the following URL for information on how to disable SELinux: If you don't want to disable SELinux, you have to allow httpd process to create network connections:
setsebool httpd_can_network_connect true

  • Mac OSX users -- if you are running MySQL on a Mac OSX, try changing $CFG->dbhost from 'localhost' to ''

See also: MySQL page on common errors which lists several possible scenarios for connection failure, with advice on how to fix the problems.

Table of Contents

I can't log in - I just stay stuck on the login screen

The most common cause for this is that your own computer (not your Moodle server) has a firewall that is stripping referrer information from the browser. Here are some instructions for fixing Norton firewall products.

The server admin can also fix this for everyone by changing the secureforms variable to 'No' in the security section of Administration >> Configuration >> Variables.

Another possible cause of this problem is that sessions are not configured properly on the server. You can test this by calling the script http://yourserver/moodle/lib/session-test.php.

If you are still having problems, read the Cannot log in page.

Table of Contents

I can't log in with message "Please verify that the current setting of session.save_path is correct"

This error occurs when PHP is having problems saving its session files. You may also see these other error messages displayed on the screen or in your log files:

Warning: Unknown: open(some-path/sessions/sess_acbf942a7399db3489ffa910e35d5242, O_RDWR)
failed: Permission denied (13) in Unknown on line 0
Warning: Unknown(): open(some-path/sessions/sess_acbf942a7399db3489ffa910e35d5242, O_RDWR) 
failed: No space left on device (28) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current 
setting of session.save_path is correct (some-path/sessions) in Unknown on line 0 

To temporarily bypass these errors, use database sessions by editing your moodle configuration file and adding this line:

$CFG->dbsessions = true;

Database sessions may overload your mysql database and are not ideal in a shared hosting environment, so if this solves the problem, you can start fixing the problem as follows:

  • Check access rights. The session.save_path should be accessible by the apache user. Try this command:
chown -R apache:apache some-path/sessions
This assumes that 'apache' is the name of the user your webserver runs under - it could also be 'nobody'.
  • Check the permissions to the directory that PHP is trying to save to (session.save_path = some-path/sessions). Set the permissions initially to 0777 (everyone read, write, execute) with this command:
chmod -R 0777 some-path/sessions
If this fixes the problem, reduce the permissions (700 is recommended).

See also: Session problems can be specific to your server environment. As an example, see this forum discussion about session problems with Lycos hosting.

Table of Contents

I log in but the login link doesn't change. I am logged in and can navigate freely.

Make sure the URL in your
setting is exactly the same as the one you are actually using to access the site.

Table of Contents

I keep getting this error: A server error that affects your login session was detected.

Please refer to the Using Moodle forum discussion A server error that affects your login session was detected. Please login again or restart your browser..

Table of Contents

I keep getting this error: Failed opening required '/web/moodle/lib/setup.php'

In your config.php, the setting that you use for the dirroot variable must be the complete path from the root of your server's hard drive.

Sometimes people only use the path from their home directory, or relative to the root of the web server directory.

Table of Contents

My pages show fatal errors such as : Parse error, call to undefined function: get_string()

If you see errors like:

Parse error: parse error, unexpected T_VARIABLE in /path/to/moodle/config.php on line 94 
Fatal error: Call to undefined function: get_string() in /path/to/moodle/mod/resource/lib.php
on line 11

then you have probably left out a semi-colon or closing quote from a line in config.php (previous to line 94).

Another possibility is that you edited config.php in a program like Word and saved it as a HTML web page, instead of using a plain text editor like Notepad.

Another thing to check, particularly if you are using 3rd party modules or plugins, is whether any of the php scripts use short open tags (<? ?>) instead of proper ones (<?php ?>). Short tags are bad for various reasons, so first contact the author of that extension to tell them about the problem. Then either replace short tags with conventional ones, or set this line in php.ini:

short_open_tag = On

You should never find short tags in core moodle code. If you do, please file a bug in the bug tracker.

Table of Contents

Serious Error! Could not set up the site!

Please refer to the Using Moodle forum discussion Serious Error! Could not set up the site!.

Table of Contents

Uploaded files give "File not found"

For example: Not Found: The requested URL /moodle/file.php/2/myfile.jpg was not found on this server.

Your web server needs to be configured to allow the part of the URL after a script name to be passed directly to the script. This is usually enabled in Apache 1, but is usually disabled by default in Apache 2. To turn it on, add this line to your httpd.conf, or to a .htaccess file in your local directory (see Installing Moodle for more details):

AcceptPathInfo on

Note, this will ONLY work for Apache versions 2.x.

If you are not using Apache 2 and you still have this problem (unlikely) then you can switch Moodle to use an alternative method. The disadvantages are a slight loss of performance for your users and you won't be able to use relative links within HTML resources.

To use this alternative method, you should change the slasharguments variable. For moodle versions < 1.7, this is located in the Operating System section of Administration > Configuration > Variables. In later versions, this option is located in Site Administration > Server > HTTP. You should now be able to access your uploaded files.

Table of Contents

When I go to the admin page, I get told to make dirroot blank!

If you see errors like this:

Please fix your settings in config.php: 
You have: $CFG->dirroot = "/home/users/fred/public_html/moodle"; 
but it should be: $CFG->dirroot = "";

then you have encountered a small bug that occurs on some servers. The problem is with the error-checking mechanism, not with your actual path. To fix it, find this line (line 66) in the file admin/index.php:

if ($dirroot != $CFG->dirroot) {

and change it to this:

if (!empty($dirroot) and $dirroot != $CFG->dirroot) {

Table of Contents

When trying to add a resource I receive error messages

Assuming you are using Apache, then it's quite likely that your setting in config.php for
is different from the actual URL you are using to access the site. Also try turning off the secureforms variable in the security section of Administration >> Configuration >> Variables.

Table of Contents

Why are all my pages blank?

Check the dirroot variable in config.php. You must use complete, absolute pathnames e.g.

$CFG->dirroot = "d:\inetpub\sites\\web\moodle";

Another reason might be that PHP has not been configured to support MySQL. This is common on Redhat and OpenBSD installations. In this case, an error is generated, but since error displays are often disabled by default, all that is seen on the browser is a blank screen. To enable PHP error displays, set these lines in your php.ini file and reload the web page.

display_errors = On
display_startup_errors = On

To determine if MySQL support is your problem, insert this as the second line in your config.php file


then reload the web page. Examine the output closely to see if MySQL is supported. If not look for a package you are missing.

Table of Contents

Why is a particular page blank or incomplete?

  • Check your web server log files!!
If a particular page is blank or incomplete (it doesn't display the footer), before you do anything else check your error logs. Having established that PHP error logging is working, reproduce the error. Immediately check the error log file right at the end. Hopefully you will see a PHP error message at or very near the end of the file. This may solve your problem directly or makes it a lot easier to diagnose the problem in the Moodle forums.
  • If you are upgrading to a new version of Moodle, check that you do not have an old version of a non-standard block or module installed. Remove any such blocks or modules installed using the admin settings page and start the install process again. However, do also make sure that you have included all optional plugins that were required by your courses.
  • If you do not see any blocks listed, turn editing on and remove any blocks that you have added to that page and try reloading.

Table of Contents

Installation hangs when setting-up database tables

  • Sometimes the installation will hang when setting up tables. This will be an abrupt hang with half the page displayed in the browser and/or other outputs removed, e.g. the “Scroll to continue” link is displayed but no “Continue” button is there. If this is the case, it is usually a mysql error and not a php error. Check that there is no limit placed on your mysql database, e.g. a "questions" limit.
  • If the install is on a webhost, adding the following line to the .htaccess file in the moodle directory has been known to solve the problem.
AddType x-mapp-php5 .php
  • Try also renaming the .htaccess file so that it is disabled.
  • You may also want to look and see if you've customized any of your code. Look at the last successful table, and then look at the block, mod, or other code that is referenced by that table. For example, if your install hangs and continues to say that the forum tables were successful as the last message, look at /mod/forum/ for any custom code. If you have customized code, backup those files and replace with the correct files. You can then restart the install by renaming config.php or reinstalling your database from the backup. If your install is successful, you can make your code changes back into the stock Moodle code.
  • It may also be that the "memory_limit" in your php.ini is set too low. Please check your php.ini file and allocate the recommended amount (see Moodle requirements). For Moodle version 1.8 and above at least 40MB is recommended.
  • A work-around to this problem is to setup a working Moodle system on your local PC or server using the Moodle Packages. Once you have a running Moodle, backup the database and import to your webhost. Then backup the Moodle code itself (the "moodle" directory on your PC) and copy this to your webhost using (for example) FTP. Finally, edit the moodle/config.php file for the new settings that have to be changed for the webhost.
  • To avoid this problem when upgrading, prefer to upgrade incrementally. For example: upgrade from 1.6.* to 1.7.* and then to 1.8.* rather than straight from 1.6.* to 1.8.*

Note: When upgrading an existing database, the installation may appear to hang at the roles generation phase. This process can take a very long time - so please be patient.

Table of Contents

Why can't I upload a new image into my profile?

If you don't see anything on your user profile pages to let you upload user images then it's usually because GD is not enabled on your server. GD is a library that allows image processing.

1. Make sure GD has been included in your PHP installation. You can check this by going into Administration >> Configuration >> Variables and looking for the gdversion setting. This setting is chosen automatically every time you visit that page. If it shows GD version 1 or version 2 then everything should be fine. Save that configuration page and go back to your user profile.

2. If Moodle thinks GD is not installed, then you will need to install the GD library.

  • On Unix you may need to re-compile PHP with arguments something like this:
./configure --with-apxs=/usr/local/apache/bin/apxs --with-xml --with-gd 
--with-jpeg-dir=/usr/local --with-png-dir=/usr --with-ttf --enable-gd-native-ttf 
--enable-magic-quotes --with-mysql --enable-sockets --enable-track-vars 
--enable-versioning --with-zlib
  • On Windows this is usually a matter of "turning on" the extension in PHP by editing your php.ini file. To do this remove the semicolon for the php_gd2.dll extension - check that this file is actually present in your php extensions folder first (search your php.ini for extension_dir to determine where this points to on your hard disk). You should then have a line that looks like this:
Windows users should see the installation instructions for further help.

3. Remember to restart your webserver (if possible) and re-visit the Moodle configuration page after making any changes to PHP so it can pick up the correct version of GD.

See also: Using Moodle forum discussion Profile pictures for additional information.

Table of Contents

Why do I keep getting error messages about "headers already sent"?

If you see errors like this:

Warning: Cannot add header information - headers already sent by 
(output started at /webs/moodle/config.php:87) in /webs/moodle/lib/moodlelib.php 
on line 1322 
Warning: Cannot add header information - headers already sent by 
(output started at /webs/moodle/config.php:87) in /webs/moodle/lib/moodlelib.php 
on line 1323 
Warning: Cannot add header information - headers already sent by 
(output started at /webs/moodle/config.php:87) in /webs/moodle/login/index.php 
on line 54
you have blank lines or spaces after the final
in your config.php file. Sometimes text editors add these - for example Notepad on Windows - so you may have to try a different text editor to remove these spaces or blank lines completely.

Table of Contents

Why doesn't my Moodle site display the time and date correctly?

Each language requires a specific language code (called a locale code) to allow dates to be displayed correctly. The language packs contain default standard codes, but sometimes these don't work on Windows servers.

You can find the correct locale codes for Windows on these two pages: Language codes and Country/region codes (e.g. "esp_esp" for spanish)

These new locale codes can be entered on the Administration >> Configuration >> Variables page, where they override the ones in the currently chosen language pack.

I receive this error "500:Internal Server Error"

There are several possible causes for this error:

1. Syntax error: There is a syntax error in your .htaccess or httpd.conf files. The way in which directives are written differs depending on which file you are using. You can test for configuration errors in your Apache files using the command:

#apachectl configtest

2. PHPsuexec: Your server does not support .htaccess files, especially if it is running PHPsuexec, which is an Apache module used for increasing the security of a site on a hosted system. In this situation:

- you may also see a 403: Forbidden error.

- the webserver executes under your own username and all files have a maximum permissions level of 755. Check that this is set for your Moodle directory in your control panel or (if you have access to the shell) use this command:

#chmod -R 755 moodle

- use a PHP.INI file instead of a .htaccess in the directory where the Moodle PHP script is being executed. For example: if you are receiving a memory exhausted error when your server is executing the file moodle/admin/cron.php, use a PHP.INI file to change your memory_limit and copy it to the moodle/admin directory. Remember that PHP.INI files are per-directory, so you'll need to copy it to each sub-directory. The syntax used in a PHP.INI file is different to a .htaccess file and you need to take out php_value/php_flag at the beginning of the line and use an equals sign to assign a value, e.g.

php_value memory_limit 128M <-- .htaccess
memory_limit = 128M         <-- php.ini equivalent 

3. Incompatible directive: You may have a directive in your .htaccess or httpd.conf files which are not compatible with your web server version. Check your webserver documentation.

Table of Contents

How do I uninstall Moodle?

Moodle package installation: If you have downloaded a Moodle package, simply uninstall using your system commands. On Windows PCs, you should access the Control Panel -> Add/Remove Programs. Select the package name and click Change or Remove Programs.

Webhost/manual installation: If you have installed Moodle manually or have installed onto a webhost, follow these steps:

  • Delete the moodle database using this mysql command (or delete using your mysql client, e.g. PHPMyAdmin):
sql>DROP DATABASE moodle;
In the above example replace 'moodle' with the name of the moodle database you created when installing.
  • Delete the moodledata directory. If you, or your users, have uploaded materials into this directory take a copy of these before deleting this directory.
  • Delete the moodle directory itself. This will delete all of the moodle PHP script files.

Table of Contents

How do I upgrade Moodle? Do I just overwrite the files?

Do not overwrite files, it may cause strange errors. You should read the Upgrade documentation before proceeding.

Migrating Moodle to a new site or server

Migrating Moodle means that you have to move the current installation to a new server, and so may have to change IP addresses or DNS entries. To do this you will need to change the $CFG->wwwroot value in the config.php on the new server. You will also have to change any absolute links stored in the database backup file (before restoring the file on the new server) either using the admin/replace.php script, your text editor or another "search and replace" tool, e.g. sed. For more details see the Moodle Migration page.

Table of Contents

Fatal error allowed memory size exhausted. How do I increase my php memory limit?

You will sometimes see an error message something like this:

Fatal error: Allowed memory size of 67108864 bytes exhausted 
(tried to allocate xx bytes) in /var/www/moodle/yyyy.php

This error means that the php memory_limit value is not enough for the php script. The memory_limit value is the "allowed memory size" - 64M in the example above (67108864 bytes / 1024 = 65536 KB. 65536 KB / 1024 = 64 MB). You will need to increase the php memory_limit value until this message is not shown anymore. There are two methods of doing this.

  • On a hosted installation, add the following line to your .htaccess file (or create one in the moodle directory if it does not already exist):
php_value memory_limit <value>M
Example: php_value memory_limit 40M
  • If you have your own server with shell access, edit your php.ini file (make sure it's the correct one by checking in your phpinfo output) as follows:
memory_limit <value>M
Example: memory_limit 40M

Remember that you need to restart your web server to make changes to php.ini effective. An alternative is to disable the memory_limit by using the command memory_limit 0.

Table of Contents

Why does my new installation display correctly on the server, but when I view it from a different machine, styles and images are missing?

In the installation instructions, one of the suggested settings for 'webroot' is 'localhost'. This is fine if all you want to do is some local testing of your new Moodle installation. If, however, you want to view your new installation from another machine on the same local area network, or view your site on the internet, you will have to change this setting:

  • For local testing, 'localhost' is fine for the webroot ($CFG->wwwroot in config.php).
  • If you want to test your site from other machines on the same local area network (LAN), then you will have to use the private ip address of the serving machine, (e.g. or the network name of the serving computer (e.g. network_name_of_serving_machine/moodle) as the web root. Depending on your LAN setup, it may be better to use the network name of the computer rather than its (private) ip address, because the ip address can and will change from time to time. If you don't want to use the network name, then you will have to speak to your network administrator and have them assign a permanent ip address to the serving machine.
  • Finally, if you want to test your new installation across the internet, you will have to use either a domain name or a permanent (public) ip address/moodle as your web root. To handle both types of access, see masquerading.

Table of Contents

Maximum upload file size - how to change it?

There are several places to change the maximum file upload size. The first place to check is the Administration block. Security -> Site Policies -> and look for "Maximum Uploaded File Size". This is the "maxbyte" variable found in older versions of Moodle (under Admin > Variables). Teachers may also set the maximum file size by the course administration block.

The second place to check are the server files. The php.ini file has a limit which will override any other setting. (Hint: remember to restart your server for changes to take effect). For more help see:

Table of Contents

See also