<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/35/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Szymonk</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/35/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Szymonk"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/Special:Contributions/Szymonk"/>
	<updated>2026-04-23T04:54:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Windows_installation&amp;diff=31410</id>
		<title>Windows installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Windows_installation&amp;diff=31410"/>
		<updated>2008-01-19T22:53:42Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Installation Packages==&lt;br /&gt;
If you are running a small (less than 30 users) Moodle server or just want to test Moodle on your Windows XP PC, pre-built packages are available for you to use. Here are links to pages containing step-by-step instructions for installing Moodle using install packages:&lt;br /&gt;
&lt;br /&gt;
*[[Complete install packages]] for most Windows versions&lt;br /&gt;
&lt;br /&gt;
*[[Installing_AMP#Windows| This section has a quick]] way to install a complete package on a Windows XP machine&lt;br /&gt;
&lt;br /&gt;
*[[Windows installation using XAMPP|Installation guide for Windows using XAMPP]] in case you want to retrofit&lt;br /&gt;
&lt;br /&gt;
*[[Installation guide for Windows using EasyPHP]]&lt;br /&gt;
&lt;br /&gt;
*[[Installation guide - Moodle for Windows on a USB Memory Stick]]&lt;br /&gt;
&lt;br /&gt;
== Manual Installation ==&lt;br /&gt;
For medium to large installations (e.g. a college, university or business), it is best practice to install Moodle on your server manually. &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Plan your system capacity&#039;&#039;&#039;. This involves estimating the appropriate hardware to support the number of users in your organisation. See [[Installing Moodle#How_many_users.3F| Installing Moodle ]] in the How Many Users section for a method of doing this.&lt;br /&gt;
* &#039;&#039;&#039;Install your database server&#039;&#039;&#039;. You have a choice of [http://dev.mysql.com/downloads/ MySQL] (recommended), [http://www.postgresql.org/download/ PostgreSQL], [[Installing MSSQL for PHP | Microsoft SQL Server 2005]] (only for Moodle 1.7 or later) or Oracle.&lt;br /&gt;
* &#039;&#039;&#039;Install PHP&#039;&#039;&#039;. See [http://www.peterguy.com/php/install_IIS6.html How to install PHP 5.x on Windows Server 2003 with IIS 6] for instructions.&lt;br /&gt;
* &#039;&#039;&#039;Install your web server&#039;&#039;&#039;. You have several choices - the decision as to which one to use will depend on your in-house expertise and your required level of sustainability:&lt;br /&gt;
**Apache 2 is recommended as the most tested and popular for Moodle installations. See these instructions for [[Installing Apache on Windows |manually installing Apache 2 on Windows]].&lt;br /&gt;
**IIS 6 can also be used. See the Windows forum for guidance on installation and, in particular, permission settings for using Moodle with IIS.&lt;br /&gt;
**Other webservers are known to install on Windows, e.g. Lighttpd, so you may wish to experiment with these if available memory is low on your server.&lt;br /&gt;
* &#039;&#039;&#039;Install Moodle&#039;&#039;&#039; by getting the standard installation for Moodle from [http://download.moodle.org/ http://download.moodle.org/] and read [[Installing Moodle]] which has detailed generic information.&lt;br /&gt;
* &#039;&#039;&#039;Setup backups&#039;&#039;&#039;. Once Moodle is setup and configured, you should setup backups of the system in case of failure or loss of data. &lt;br /&gt;
** &#039;&#039;&#039;To perform full site backups&#039;&#039;&#039; you need to backup the moodledata and moodle directories, Apache webserver configuration (httpd.conf) if you&#039;re using Apache, PHP configuration (php.ini) and any php extensions which are non-standard, and the mysql database. To do this use the integrated backup program (Start -&amp;gt; All Programs -&amp;gt; Accessories -&amp;gt; System Tools -&amp;gt; Backup) or your own proprietary backup software (e.g. BackupExec). To backup your mysql database see the [[Backup FAQ]].&lt;br /&gt;
** &#039;&#039;&#039;To perform course backups&#039;&#039;&#039; see the [[Course backup]] page.&lt;br /&gt;
** You should also perform a &#039;&#039;&#039;state backup&#039;&#039;&#039; of the [http://technet2.microsoft.com/WindowsServer/en/library/921f0ed5-523d-48ac-8825-e850b0e548841033.mspx?mfr=true server] or [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntbackup_backup_sysstate.mspx?mfr=true PC]. This is especially important if you&#039;re using IIS as this will backup the IIS metabase. &lt;br /&gt;
* &#039;&#039;&#039;Check your server security and performance&#039;&#039;&#039;. It is also good practice to read the [[Performance]] and [[Security]] documentation. Although much of the content is targetted at Linux/Unix users, there is a growing amount for Windows systems.&lt;br /&gt;
* Set-up your &#039;&#039;&#039;Active Directory authentication&#039;&#039;&#039;. You can use the standard [[LDAP authentication]] which prompts users with a username/password, or [[NTLM authentication | integrated NTLM authentication]] which does not require campus users to enter their credentials.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/view.php?id=6799 Windows-based server forum] is the main forum for asking questions about your Moodle Windows installation.&lt;br /&gt;
* [[Installing APC in Windows]] contains instructions for using a PHP accelerator to reduce processor load.&lt;br /&gt;
* [[Cron | Installing Cron on Windows]] for setting up the Moodle scheduled task.&lt;br /&gt;
* [[Configuring aspell on Windows 2003 Server]] for setting up the Moodle spell checker.&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=56835 Running Apache and IIS on the same server] forum discussion.&lt;br /&gt;
* [http://moodle.org/blog/index.php?userid=212926&amp;amp;courseid=55 A Windows installation log.]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[pl:Instalacja w Windows]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Installing_APC_in_Windows&amp;diff=31409</id>
		<title>Installing APC in Windows</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Installing_APC_in_Windows&amp;diff=31409"/>
		<updated>2008-01-19T22:10:11Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
APC (Alternative PHP Cache) is a PHP opcode cache. It stores PHP pages in RAM and reduces hard disk activity. This makes a real difference to the performance in Moodle, and you should be able to achieve a 50% increase in system capacity and your CPU will be 50% less busy.&lt;br /&gt;
&lt;br /&gt;
This guide is for installation of APC on a Windows server. The instructions have been tested on a Windows 2003 server, and they should also be applicable if you are using Windows XP as a test server.&lt;br /&gt;
&lt;br /&gt;
==Installation on Windows Server==&lt;br /&gt;
&#039;&#039;&#039;Warning: You cannot install APC and Zend Optimiser on the same server. You should choose one or the other.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Follow these steps to install APC.&lt;br /&gt;
&lt;br /&gt;
===Download the correct version===&lt;br /&gt;
Download the windows binary for the PHP version you have installed from http://pecl4win.php.net/ext.php/php_apc.dll. Save into the PHP extensions folder, which is c:\php\ext by default.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure you choose the right extension for your version (branch) of PHP.&lt;br /&gt;
&lt;br /&gt;
===Enable the APC extension in your PHP.INI file===&lt;br /&gt;
Edit the php.ini file and add the following line in the extensions section:&lt;br /&gt;
&lt;br /&gt;
 extension = php_apc.dll&lt;br /&gt;
&lt;br /&gt;
Check that this has worked by restarting your web server and looking at the output of phpinfo from the Moodle administration screens or from a text file containing this line: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php phpinfo(); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Check the memory available===&lt;br /&gt;
To check the amount of memory that is available for APC to use:&lt;br /&gt;
&lt;br /&gt;
* Run WordPad and create a text file called apcmeminfo.php.&lt;br /&gt;
* Copy and paste this line into the file&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php print_r(apc_sma_info()); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Save the file into moodle/admin/apcmeminfo.php&lt;br /&gt;
* Browse to http://mymoodle.com/moodle/admin/apcmeminfo.php.&lt;br /&gt;
* Note the avail_mem value (in bytes)&lt;br /&gt;
&lt;br /&gt;
 ... [avail_mem] =&amp;gt; 31447368 ... &lt;br /&gt;
&lt;br /&gt;
The total amount of memory used by the cache is given by this formula:&lt;br /&gt;
&lt;br /&gt;
 total_memory = apc.shm_segments * apc.shm_size&lt;br /&gt;
&lt;br /&gt;
In this example, the available memory is approx 32Mb. Usually if we need more than 32Mb in our cache, we should increase the number of segments that APC uses. However, this is can cause web server faults, so it is best to increase the segment size instead.&lt;br /&gt;
&lt;br /&gt;
When setting the total memory available for the cache, start with the lowest that a single Moodle install can work with (64Mb). This amount may not be enough if you have extra modules and blocks installed, so check by monitoring the cache regularly in the first two weeks that your server is running. Look at the monitoring section below and gradually increase your total cache memory until there is no more cache churn.&lt;br /&gt;
&lt;br /&gt;
===Customizing APC settings for Moodle===&lt;br /&gt;
The default APC settings are as follows:&lt;br /&gt;
&lt;br /&gt;
 apc.cache_by_default = On&lt;br /&gt;
 apc.enable_cli = Off&lt;br /&gt;
 apc.enabled = On&lt;br /&gt;
 apc.file_update_protection = 2&lt;br /&gt;
 apc.filters = &#039;&#039;&lt;br /&gt;
 apc.gc_ttl = 3600&lt;br /&gt;
 apc.include_once_override = Off&lt;br /&gt;
 apc.max_file_size = 1M&lt;br /&gt;
 apc.num_files_hint = 1000&lt;br /&gt;
 apc.optimization = Off&lt;br /&gt;
 apc.report_autofilter = Off&lt;br /&gt;
 apc.shm_segments = 1&lt;br /&gt;
 apc.shm_size = 30&lt;br /&gt;
 apc.slam_defense = 0&lt;br /&gt;
 apc.stat = On&lt;br /&gt;
 apc.ttl = 0&lt;br /&gt;
 apc.user_entries_hint = 100&lt;br /&gt;
 apc.user_ttl = 0&lt;br /&gt;
 apc.write_lock = On&lt;br /&gt;
&lt;br /&gt;
For a full explanation of these settings, see http://www.php.net/apc.&lt;br /&gt;
&lt;br /&gt;
For a general Moodle installation several changes are needed. These are: &lt;br /&gt;
* The apc.shm_size (the size of the cache) which should be set initially to 64Mb.&lt;br /&gt;
* The apc.shm_segments which should be set to 1. This gives a total initial cache size of 64Mb.&lt;br /&gt;
* The apc.stat (file stating) which should be set to 1 otherwise you may get blank pages.&lt;br /&gt;
* The apc.max_file_size setting which should be increased to 10Mb.&lt;br /&gt;
&lt;br /&gt;
Note that to disable APC temporarily set apc.enabled = 0 in PHP.INI and restart your webserver.&lt;br /&gt;
&lt;br /&gt;
A working APC section of of PHP.INI is shown below, so copy and paste the following at the end of your PHP.INI file:&lt;br /&gt;
&lt;br /&gt;
 [APC]&lt;br /&gt;
 apc.enabled = 1&lt;br /&gt;
 apc.shm_segments = 1&lt;br /&gt;
 apc.shm_size = 64&lt;br /&gt;
 apc.max_file_size = 10M&lt;br /&gt;
 apc.stat=1&lt;br /&gt;
 &lt;br /&gt;
The remainder of the settings can be left as their default.&lt;br /&gt;
&lt;br /&gt;
===Set the temp directory===&lt;br /&gt;
APC needs a temporary directory to save its files. It will attempt to save the files in the windows temp directory, so set the C:\WINDOWS\TEMP directory to be writable by the web server user (for IIS this is IUSR_machine-name, for Apache no change to permissions are necessary), e.g. at least Read &amp;amp; Execute permissions.&lt;br /&gt;
&lt;br /&gt;
==Monitoring and tuning the cache==&lt;br /&gt;
The APC source contains a php script that is useful for monitoring and tuning the performance of your cache.&lt;br /&gt;
&lt;br /&gt;
* Download the APC monitoring file from http://pecl.php.net/package/apc and extract the contents. &lt;br /&gt;
* Look for the file apc.php as this is the file that displays APC monitoring information. &lt;br /&gt;
* Save the file apc.php into the /moodle/admin folder on your server. &lt;br /&gt;
&lt;br /&gt;
Note: Once you have successfully installed APC, move this file to a password protected area for security.&lt;br /&gt;
&lt;br /&gt;
* Verify that the script is working by browsing to http://mymoodle.com/moodle/admin/apc.php (or whatever the location of the apc.php file is on your server). You should see a graphical display of your cache with some statistical data on the left side.&lt;br /&gt;
&lt;br /&gt;
To tune the cache, look at the &#039;&#039;General Cache Information&#039;&#039; and &#039;&#039;Detailed Memory Usage and Fragmentation&#039;&#039; sections. Watch the &#039;&#039;&#039;Cache Full Count&#039;&#039;&#039; and &#039;&#039;&#039;Fragmentation %&#039;&#039;&#039; indicators. &lt;br /&gt;
* If Cache Full Count &amp;gt; 0, this indicates that the cache is filling-up and churning as there is not enough memory allocated. To solve this problem increase the memory allocation (apc.shm_size).&lt;br /&gt;
* The Fragmentation % indicator should be 0% but may increase from time-to-time especially if the cache is churning.&lt;br /&gt;
&lt;br /&gt;
==Checking performance==&lt;br /&gt;
To confirm that there has been an improvement in performance, try the following:&lt;br /&gt;
&lt;br /&gt;
* Disable the cache in PHP.INI and restart the web server.&lt;br /&gt;
* Run ab.exe (included in the apache bin folder) at the command prompt as follows:&lt;br /&gt;
&lt;br /&gt;
 c:\apache2\bin&amp;gt;ab.exe -n 50 -c 1 -d http://mymoodle.com/moodle/index.php&lt;br /&gt;
&lt;br /&gt;
* Note the transfer rate and the time per request values.&lt;br /&gt;
* Enable the cache in PHP.INI and restart the web server.&lt;br /&gt;
* Load http://mymoodle.com/moodle/index.php in your browser so that it is stored in the cache.&lt;br /&gt;
* Run ab.exe again and compare the transfer rate and time per request values. You should see an increase in both of these values by approximately 50%.&lt;br /&gt;
&lt;br /&gt;
==Uninstalling APC==&lt;br /&gt;
To uninstall APC, add a semicolon to the extension line in your PHP.INI as follows:&lt;br /&gt;
&lt;br /&gt;
 ;extension = php_apc.dll&lt;br /&gt;
&lt;br /&gt;
Remember to restart your web server.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=56900 A discussion of an alternative to APC - Xcache]&lt;br /&gt;
* [http://cvs.php.net/viewvc.cgi/pecl/apc/TECHNOTES.txt?view=co APC technical notes]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Performance]]&lt;br /&gt;
&lt;br /&gt;
[[pl:Instalacja APC w Windows]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Arguments_in_favour_of_PostgreSQL&amp;diff=31408</id>
		<title>Arguments in favour of PostgreSQL</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Arguments_in_favour_of_PostgreSQL&amp;diff=31408"/>
		<updated>2008-01-19T20:40:38Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Martin Langhoff argues &#039;&#039;&#039;in favour of PostgreSQL&#039;&#039;&#039; (source: [http://moodle.org/mod/forum/discuss.php?d=24831#121862 Moodle over webct and LNLS at Athabasca University?] forum posting)&lt;br /&gt;
&lt;br /&gt;
There are several reasons to go with Postgres, I&#039;ll try to make a brief outline. We run a variety of RDBMSs at Catalyst, and have a lot of in-house experience with them: Oracle, Postgres, MySQL and Progress, plus a few others. We also have experience with replicated databases, clustering and other tricks -- which we use for the backend of the .nz root domain servers as well as a few other mission-critical systems.&lt;br /&gt;
&lt;br /&gt;
On the performance side, Postgres requires a bit more up-front configuration than MySQL. A well tuned Postgres is pretty close on SELECT performance to MySQL with small databases. With large tables MySQL has some bad performance problems, and Postgres performs much better.&lt;br /&gt;
&lt;br /&gt;
Write performance is also an issue with MySQL -- with a lot of traffic, it has serious problems with concurrent writes. Under heavy load, Postgres performs much better.&lt;br /&gt;
&lt;br /&gt;
But to tell you the truth, the real reason for choosing Postgres is reliability. We maintain a lot of databases, and Postgres is rock-solid reliable and has a focus on ACID-correctness: when it returns from a commit, the data is safely on disk and won&#039;t be lost -- barring actual disk problems, which we offset using RAID-1.&lt;br /&gt;
&lt;br /&gt;
No matter how hard we try, MySQL databases with a lot of usage have recurring index corruption issues. If you look at the startup scripts for MySQL on most Linux distributions, they check for data corruption on every startup -- this is to mask the fact that it is a frequent occurrence.&lt;br /&gt;
&lt;br /&gt;
And while this is passable with small installations where the data isn&#039;t mission critical, you have to consider how much you can trust such approch. And with large datasets, runing isamchk/myisamchk can take hours -- we cannot afford that.&lt;br /&gt;
&lt;br /&gt;
The clustering solution for MySQL is being touted a lot, and I think it is a red herring. My main concern about is that it writes &amp;quot;asynchronously&amp;quot; -- that is, there is no guarantee that your data is on-disk safely. It&#039;ll get to the disk sometime. It&#039;ll get to the slaves... sometime. Hmmm.&lt;br /&gt;
&lt;br /&gt;
Given that the MySQL cluster uses async writes, splitting read/writes between the master and the slaves breaks down in cases where we write some data, and read it back in immediately (or soon after). And this does happen in quite a few places.&lt;br /&gt;
&lt;br /&gt;
And you also have to consider the performance boost of using async writes: if you tell a standalone Postgres or MySQL to use async writes, it&#039;ll run scale much better (should be able to handle up to 3-4 times more simultaneous writes). Once you do that, the performance advantage of the MySQL cluster mostly vanishes. It still has semi-hot takeover in case the master goes down, but Postgres can do that using Slony, and with better guarantess of consistency of the data in the slave.&lt;br /&gt;
&lt;br /&gt;
In a nutshell, MySQL isn&#039;t normally very solid when it comes to ensure my data is safely stored on-the-disk, even if it theoretically guarantees that it&#039;s been saved. And MySQL Cluster says up-front that there isn&#039;t a guarantee any more. Riiiiiight wink&lt;br /&gt;
&lt;br /&gt;
Michael is talking about having UPSs. We have a car-sized UPS and a container-sized on-site generator that auto-starts. And yet, I wouldn&#039;t depend on that for my DB consistency on a large Installation. So many things other than power can (and do) go amiss. If a process has a problem storing the data, the right thing is to tell that back to the user. With async writes, you end up with a queue of data that hasn&#039;t been stored yet, but you already told the user it was.&lt;br /&gt;
&lt;br /&gt;
That&#039;s not what a database is supposed to do.&lt;br /&gt;
&lt;br /&gt;
I am currently exploring some techniques similar to those being used in livejournal and slashdot. We should be able to increase Moodle scalability by cutting down on DB load by about 50%. This is happening slowly in the gaps between more urgent projects. Feel free to ping Richard or me if you&#039;re interested in that track.&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
* [https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Ubuntu#Install_Postgresql_.28skip_MySQL.29 Installing Postgres on Ubuntu(Debian)]&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Performance]]&lt;br /&gt;
&lt;br /&gt;
[[pl:Argumenty za PostgreSQL]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Performance_recommendations&amp;diff=31406</id>
		<title>Performance recommendations</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Performance_recommendations&amp;diff=31406"/>
		<updated>2008-01-19T19:31:07Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Location: &#039;&#039;Administration &amp;gt; Server &amp;gt; Performance&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Obtain a baseline benchmark==&lt;br /&gt;
&lt;br /&gt;
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you&#039;ll be able to determine if the change you have made as has any real impact.&lt;br /&gt;
&lt;br /&gt;
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;optimization order preference&#039;&#039;&#039; is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).&lt;br /&gt;
&lt;br /&gt;
==Scalability==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)&lt;br /&gt;
&lt;br /&gt;
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.&lt;br /&gt;
&lt;br /&gt;
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore area, but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See also&#039;&#039;&#039;: &lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=4801 Scalability] forum discussion.&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering] forum discussion.&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing] forum discussion.&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing] forum dicsussion.&lt;br /&gt;
&lt;br /&gt;
==Hardware configuration==&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: The fastest and most effective change that you can make to improve performance is to &#039;&#039;&#039;increase the amount of RAM on your web server&#039;&#039;&#039; - get as much as possible (eg 4GB). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.&lt;br /&gt;
* Better performance is gained by obtaining the best &#039;&#039;&#039;processor capability&#039;&#039;&#039; you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].&lt;br /&gt;
* If you can afford them, use &#039;&#039;&#039;SCSI hard disks&#039;&#039;&#039; instead of SATA drives. SATA drives will increase your system&#039;s CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).&lt;br /&gt;
* Purchase hard disks with a &#039;&#039;&#039;low seek time&#039;&#039;&#039;. This will improve the overall speed of your system, especially when accessing Moodle&#039;s reports.&lt;br /&gt;
* Size your &#039;&#039;&#039;swap file&#039;&#039;&#039; correctly. The general advice is to set it to 4 x physical RAM.&lt;br /&gt;
* Use a &#039;&#039;&#039;RAID disk system&#039;&#039;&#039;. Although there are many different RAID configurations you can create, the following generally works best:&lt;br /&gt;
** install a hardware RAID controller (if you can)&lt;br /&gt;
** the operating system and swap drive on one set of disks configured as RAID-1.&lt;br /&gt;
** Moodle, Web server and Database server on another set of disks configured as RAID-5.&lt;br /&gt;
* Use &#039;&#039;&#039;gigabit ethernet&#039;&#039;&#039; for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.&lt;br /&gt;
* Check the settings on your &#039;&#039;&#039;network card&#039;&#039;&#039;. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.&lt;br /&gt;
*  Read this Case Study on a server stress test with 300 users.[http://moodle.org/mod/forum/discuss.php?d=68579]  &lt;br /&gt;
*  See this accompanying report on network traffic and server loads. [http://elearning.sgu.ac.jp/doc/PT/]&lt;br /&gt;
&lt;br /&gt;
==Operating System==&lt;br /&gt;
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server &#039;&#039;&#039;operating system&#039;&#039;&#039;. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you&#039;re used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].&lt;br /&gt;
* Check your own OS and &#039;&#039;&#039;vendor specific instructions&#039;&#039;&#039; for optimization steps.&lt;br /&gt;
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. &lt;br /&gt;
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the async and noatime options.&lt;br /&gt;
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File &amp;amp; Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.&lt;br /&gt;
&lt;br /&gt;
==Web server performance==&lt;br /&gt;
&lt;br /&gt;
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo&#039;s [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules] ([http://video.yahoo.com/video/play?vid=1040890 video]) for fast loading websites.&lt;br /&gt;
&lt;br /&gt;
===PHP performance===&lt;br /&gt;
* You are strongly recommended to use a &#039;&#039;&#039;PHP accelerator&#039;&#039;&#039; to ease CPU load, such as [http://pecl.php.net/apc APC] (recommended), [http://www.php-accelerator.co.uk/ PHPA], [http://trac.lighttpd.net/xcache/ Xcache] or [http://eaccelerator.net/ eAccelerator]. (Take care to choose a PHP accelerator that is known to work well with your version of PHP and note that Turck MMCache is [http://turckmmcache.exeprod.com/TheManifestoEnglish no longer maintained] and can cause failures with PHP 5). Put the cached PHP pages on a [[TMPFS]] filesystem.&lt;br /&gt;
* Performance of PHP is better when installed as an &#039;&#039;&#039;Apache/IIS ISAPI module&#039;&#039;&#039; (rather than a CGI).&lt;br /&gt;
* Also check the &#039;&#039;&#039;memory_limit&#039;&#039;&#039; in php.ini, reduce it to 16M for Moodle version earlier than 1.7 ([http://moodle.org/mod/forum/discuss.php?d=39656 See this forum discussion]). For Moodle 1.7 or later, it is recommended that the value of memory_limit should be 40M.&lt;br /&gt;
&lt;br /&gt;
===Apache performance===&lt;br /&gt;
* Set the &#039;&#039;&#039;MaxClients&#039;&#039;&#039; directive correctly. Use this formula to help (which uses 80% of available memory to leave room for spare):&lt;br /&gt;
 MaxClients = Total available memory * 80% / Max memory usage of apache process&lt;br /&gt;
:Memory usage of apache process is usually 10MB, so a general rule of thumb is to divide your available memory in megabytes by 10 to get the value of MaxClients. To find the max memory usage of apache processes read the value from the shell command:&lt;br /&gt;
 #ps -ylC httpd --sort:rss&lt;br /&gt;
&lt;br /&gt;
:If you need to increase the value of &#039;&#039;&#039;MaxClients&#039;&#039;&#039; beyond 256, you will also need to set the &#039;&#039;&#039;ServerLimit&#039;&#039;&#039; directive. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: Do not be tempted to set the value of MaxClients higher than your available memory as your server will consume more RAM than available and start to swap to disk. &lt;br /&gt;
* Consider reducing the &#039;&#039;&#039;number of modules&#039;&#039;&#039; that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. &lt;br /&gt;
* Use the &#039;&#039;&#039;latest version of Apache&#039;&#039;&#039; - Apache 2 has an improved memory model which reduces memory usage further.&lt;br /&gt;
* For Unix/Linux systems, consider lowering &#039;&#039;&#039;MaxRequestsPerChild&#039;&#039;&#039; in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). &lt;br /&gt;
* For a heavily loaded server, consider setting &#039;&#039;&#039;KeepAlive Off&#039;&#039;&#039; (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the &#039;&#039;&#039;KeepAliveTimeout&#039;&#039;&#039; to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.&lt;br /&gt;
* As an alternative to using KeepAlive Off, consider setting-up a &#039;&#039;&#039;Reverse Proxy server&#039;&#039;&#039; infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.&lt;br /&gt;
* If you do not use a .htaccess file, set the &#039;&#039;&#039;AllowOverride&#039;&#039;&#039; variable to AllowOverride None to prevent .htaccess lookups.&lt;br /&gt;
* Set &#039;&#039;&#039;DirectoryIndex&#039;&#039;&#039; correctly so as to avoid content-negotiation. Here&#039;s an example from a production server:&lt;br /&gt;
 DirectoryIndex index.php index.html index.htm&lt;br /&gt;
* Unless you are doing development work on the server, set &#039;&#039;&#039;ExtendedStatus Off&#039;&#039;&#039; and disable mod_info as well as mod_status.&lt;br /&gt;
* Leave &#039;&#039;&#039;HostnamesLookups Off&#039;&#039;&#039; (as default) to reduce DNS latency.&lt;br /&gt;
* Consider reducing the value of &#039;&#039;&#039;TimeOut&#039;&#039;&#039; to between 30 to 60 (seconds). &lt;br /&gt;
* For the &#039;&#039;&#039;Options directive&#039;&#039;&#039;, avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use&lt;br /&gt;
 Options -Indexes FollowSymLinks&lt;br /&gt;
*&#039;&#039;&#039;Caching&#039;&#039;&#039; - Apache can be told to make pages load a lot faster by specifying that the browser should cache some various page elements such as images and reuse them from local memory rather than ask for them again every time a page is requested. How to do this varies slightly between OSes but there are two basic steps:&lt;br /&gt;
&lt;br /&gt;
# Install and enable mod_expires - refer to documentation or man pages&lt;br /&gt;
# Add this code to the virtual server config file within the &amp;lt;directory&amp;gt; section for the root directory (or within the .htaccess file if AllowOverrides is On):&lt;br /&gt;
 &amp;lt;IfModule mod_expires.c&amp;gt;&lt;br /&gt;
  ExpiresActive On&lt;br /&gt;
  ExpiresDefault &amp;quot;access plus 1 seconds&amp;quot;&lt;br /&gt;
  ExpiresByType text/html &amp;quot;access plus 1 seconds&amp;quot;&lt;br /&gt;
  ExpiresByType image/gif &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType image/jpeg &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType image/png &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType text/css &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType text/javascript &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType application/x-javascript &amp;quot;access plus 1 week&amp;quot;&lt;br /&gt;
  ExpiresByType text/xml &amp;quot;access plus 1 seconds&amp;quot;&lt;br /&gt;
 &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect is to make everything stay in the cache except HTML and XML, which change dynamically. It&#039;s possible to gain a several hundred percent decrease in load times this way. Adjust the cache times according to how often your images etc change.&lt;br /&gt;
&lt;br /&gt;
More info: [http://www.metaskills.net/blog/heuristics/sysadmin/how-to-control-browser-caching-with-apache-2 www.metaskills.net]&lt;br /&gt;
&lt;br /&gt;
* Alternatively, you can increase web server performance by using the &#039;&#039;&#039;light-weight webserver&#039;&#039;&#039; [http://www.lighttpd.net/ lighttpd] in combination with PHP in fastCGI-mode instead of Apache. Lighttpd has a lower memory consumption than Apache. One single apache process requires more RAM than the whole lighttpd with all of its fastCGI-processes together. Note that Lighttpd is relatively difficult to configure and administration takes a more time.&lt;br /&gt;
&lt;br /&gt;
===IIS performance===&lt;br /&gt;
All alter this location in the registry:&lt;br /&gt;
 HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\&lt;br /&gt;
* The equivalent to KeepAliveTimeout is &#039;&#039;&#039;ListenBackLog&#039;&#039;&#039; (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.&lt;br /&gt;
*Change the &#039;&#039;&#039;MemCacheSize&#039;&#039;&#039; value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).&lt;br /&gt;
*Change the &#039;&#039;&#039;MaxCachedFileSize&#039;&#039;&#039; to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).&lt;br /&gt;
*Create a new DWORD called &#039;&#039;&#039;ObjectCacheTTL&#039;&#039;&#039; to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).&lt;br /&gt;
&lt;br /&gt;
==Database performance==&lt;br /&gt;
&lt;br /&gt;
Moodle contains a script which will display some key database performance statistics from the [http://phplens.com/lens/adodb/docs-perf.htm ADOdb performance monitor]. Run the script in your browser as in the following example:&lt;br /&gt;
&lt;br /&gt;
 http://www.mymoodle.com/admin/dbperformance.php&lt;br /&gt;
&lt;br /&gt;
Use the data displayed as a guide to tune and improve the performance of your database server.&lt;br /&gt;
&lt;br /&gt;
===MySQL performance===&lt;br /&gt;
&lt;br /&gt;
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands&lt;br /&gt;
 SHOW STATUS;&lt;br /&gt;
 SHOW VARIABLES; &lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.&lt;br /&gt;
* Enable the &#039;&#039;&#039;query cache&#039;&#039;&#039; with &lt;br /&gt;
 query_cache_type = 1. &lt;br /&gt;
For most Moodle installs, set the following:&lt;br /&gt;
 query_cache_size = 36M &lt;br /&gt;
 query_cache_min_res_unit = 2K. &lt;br /&gt;
The query cache will improve performance if you are doing few updates on the database. &lt;br /&gt;
* Set the &#039;&#039;&#039;table cache&#039;&#039;&#039; correctly. For Moodle 1.6 set &lt;br /&gt;
 table_cache = 256 &lt;br /&gt;
(min), and for Moodle 1.7 set &lt;br /&gt;
 table_cache = 512 &lt;br /&gt;
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables &amp;gt; 3 * table_cache then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.&lt;br /&gt;
 mysql&amp;gt;SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema=&#039;yourmoodledbname&#039;;&lt;br /&gt;
* Set the &#039;&#039;&#039;thread cache&#039;&#039;&#039; correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:&lt;br /&gt;
 thread cache utilization (%) = (threads_created / connections) * 100&lt;br /&gt;
* The &#039;&#039;&#039;key buffer&#039;&#039;&#039; can improve the access speed to Moodle&#039;s SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:&lt;br /&gt;
 key_read / key_read_requests &amp;lt; 0.01&lt;br /&gt;
 key_write / key_write_requests &amp;lt;= 1.0&lt;br /&gt;
* Set the &#039;&#039;&#039;maximum number of connections&#039;&#039;&#039; so that your users will not see a &amp;quot;Too many connections&amp;quot; message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.&lt;br /&gt;
* Manage &#039;&#039;&#039;high burst activity&#039;&#039;&#039;. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.&lt;br /&gt;
* &#039;&#039;&#039;Optimize your tables weekly and after upgrading Moodle&#039;&#039;&#039;. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:&lt;br /&gt;
 mysql&amp;gt;CHECK TABLE mdl_tablename;&lt;br /&gt;
 mysql&amp;gt;OPTIMIZE TABLE mdl_tablename;&lt;br /&gt;
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).&lt;br /&gt;
* &#039;&#039;&#039;Maintain the key distribution&#039;&#039;&#039;. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.&lt;br /&gt;
 #myisamchk -a -S /pathtomysql/data/moodledir/*.MYI&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.&lt;br /&gt;
* Reduce the number of &#039;&#039;&#039;temporary tables saved to disk&#039;&#039;&#039;. Check this with the created_tmp_disk_tables value. If this is relatively large (&amp;gt;5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.&lt;br /&gt;
* Moodle&#039;s tables are in the MyISAM format, so &#039;&#039;&#039;turn InnoDB off&#039;&#039;&#039; as there is no performance gain. Add &amp;lt;code&amp;gt;skip-innodb&amp;lt;/code&amp;gt; to your &amp;lt;code&amp;gt;my.cnf&amp;lt;/code&amp;gt; file. If you must use InnoDB, you&#039;ll have to convert all of Moodle&#039;s tables. To do this run the innodb script:&lt;br /&gt;
&lt;br /&gt;
 http://www.mymoodle.com/admin/innodb.php&lt;br /&gt;
&lt;br /&gt;
===Other database performance links===&lt;br /&gt;
* Consider using a &#039;&#039;&#039;distributed cacheing system&#039;&#039;&#039; like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.&lt;br /&gt;
* Consider using PostgreSQL. See [[Arguments in favour of PostgreSQL]] and [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).&lt;br /&gt;
* [[Increasing the database connection lifetime | Try increasing the database connection lifetime]]&lt;br /&gt;
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)&lt;br /&gt;
&lt;br /&gt;
==Moodle Admin settings==&lt;br /&gt;
* In Moodle 1.7 or later, set the &#039;&#039;&#039;Cache type&#039;&#039;&#039; for your server: Site Admin -&amp;gt; Server -&amp;gt; Performance -&amp;gt; Cache type. There are several options available. &lt;br /&gt;
:*If you do not have eaccelerator or mmemcached installed, choose &amp;quot;internal&amp;quot; (which makes use of the record/internal cache - see the next bullet point). &lt;br /&gt;
:* If you have a single server and have compiled &#039;&#039;&#039;eaccelerator with shared memory support&#039;&#039;&#039;, set the cache type to the eaccelerator option. &lt;br /&gt;
:* If you have a &#039;&#039;&#039;separate memcached server&#039;&#039;&#039;, set the cache type to memcached and enter a csv list of server IP addresses.&lt;br /&gt;
* Enable the &#039;&#039;&#039;record/internal cache&#039;&#039;&#039;: Site Admin -&amp;gt; Server -&amp;gt; Performance -&amp;gt; Record cache = True. Set the maximum amount of memory allocated to the cache in the Int Cache Max box. This will enable a primary cache for database records, without using any database engine cache, e.g. MySQL/PostgreSQL cache. See [http://tracker.moodle.org/browse/MDL-7196 this Tracker entry] for a full discussion.&lt;br /&gt;
* Enable the &#039;&#039;&#039;language cache&#039;&#039;&#039;.&lt;br /&gt;
* Large log files can cause overall performance to degrade over time. If you observe that the site has gradually got slower loading pages in the browser, &#039;&#039;&#039;reduce your Log life time&#039;&#039;&#039; setting (Admin/Server/Cleanup).&lt;br /&gt;
* Performance can be greatly improved by allowing Moodle to use the system &#039;&#039;&#039;zip/unzip&#039;&#039;&#039; commands (rather than PHP-based zip libraries) - visit Admin/Server/System Paths and enter the path to the relevant executables. (Similarly, filling in the path to &#039;&#039;&#039;du&#039;&#039;&#039; will improve Moodle&#039;s speed at listing directory contents.)&lt;br /&gt;
* Note that using &#039;&#039;&#039;secure web connections&#039;&#039;&#039; (&#039;&#039;&#039;https&#039;&#039;&#039; rather than &#039;&#039;&#039;http&#039;&#039;&#039;) carries a higher processing burden, both for the webserver and the client - particularly because cacheing cannot be used as effectively, so the number of file requests is likely to increase dramatically. For this reason using https for all Moodle pages is not recommended. You can enable https just for the login screen, simply from Moodle&#039;s config page.&lt;br /&gt;
* Check your &#039;&#039;&#039;filters&#039;&#039;&#039;. Having too many filters active can have serious effects on server load, especially on lower-end systems. The number of active filters has a direct effect on the perceived latency of your site; that is the time taken for each page impression. &lt;br /&gt;
* Enable the &#039;&#039;&#039;text cache&#039;&#039;&#039; but do not &amp;quot;Filter all strings&amp;quot; unless you have a specific need. If in doubt profile the performance, and see how your changes affect the processing time.&lt;br /&gt;
* Check your &#039;&#039;&#039;anti-virus&#039;&#039;&#039; measures on the server.  Although they are useful for preventing security holes being exploited, some &amp;quot;On-Demand&amp;quot; scanners can affect performance by scanning page content (word, ppt files etc).&lt;br /&gt;
* If there are performance problems loading course pages, check the &#039;&#039;&#039;Resource module settings&#039;&#039;&#039;. The setting resource_filterexternalpages is known to slow-down course pages and should be set to &#039;No&#039; for better performance.&lt;br /&gt;
* Check your &#039;&#039;&#039;forum settings&#039;&#039;&#039;. To improve performance set forum_trackreadposts = No and forum_usermarksread = Yes (this will impact on the convenience of your users&#039; forum experience). Also consider setting the time of the day when old posts are cleared from the read table (forum_cleanreadtime) to when your site is less busy.&lt;br /&gt;
&lt;br /&gt;
==Performance of different Moodle modules==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn&#039;t necessary. Some notes on the performance of certain modules:&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Chat&#039;&#039;&#039; module is [http://moodle.org/mod/forum/discuss.php?d=37979&amp;amp;parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use &#039;&#039;Streamed&#039;&#039; updates, or, if you&#039;re using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the &#039;&#039;chat_old_ping&#039;&#039; and &#039;&#039;chat_refresh&#039;&#039; parameters as these can have greatest impact on server load.&lt;br /&gt;
* The &#039;&#039;&#039;Quiz&#039;&#039;&#039; module is known to stretch database performance. Try to optimise your database server by tuning. See [http://moodle.org/mod/forum/discuss.php?d=25616&amp;amp;parent=120770 for a brief report on performance for 55 students simultaneously using quizzes]&lt;br /&gt;
** See this Case Study for an extensive server stress test with 300 quiz users.[http://moodle.org/mod/forum/discuss.php?d=68579]  And this accompanying report on network traffic and server loads. [http://elearning.sgu.ac.jp/doc/PT/]&lt;br /&gt;
* The Moodle &#039;&#039;&#039;Cron&#039;&#039;&#039; task is triggered by calling the script &#039;&#039;cron.php&#039;&#039;. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. &#039;&#039;php -f /path/to/moodle/directory/admin/cron.php&#039;&#039;) efficiency can be much improved.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/view.php?f=94 Servers and Performance] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script] forum discussion&lt;br /&gt;
&lt;br /&gt;
There have been a lot of discussions on moodle.org about performace, here are some of the more interesting and (potentially) useful ones:&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]&lt;br /&gt;
&lt;br /&gt;
[[Category:Performance]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Performance]]&lt;br /&gt;
[[ja:パフォーマンス]]&lt;br /&gt;
[[pl:Wydajność]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=PHP&amp;diff=31389</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=PHP&amp;diff=31389"/>
		<updated>2008-01-18T19:34:34Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PHP is the scripting language in which Moodle is developed. PHP does not stand alone, it is tightly integrated with a suitable HTTP Server. Most people use the [[Apache]] HTTP Server for this purpose although a number of others are supported.&lt;br /&gt;
&lt;br /&gt;
PHP describes itself as &amp;quot;a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into [[HTML]].&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Usually PHP is installed alongside [[Apache]] and [[MySQL]] in a combination known as AMP, see [[Installing AMP]] for details.&lt;br /&gt;
&lt;br /&gt;
== Minimum version requirements ==&lt;br /&gt;
&lt;br /&gt;
The minimum version of PHP required for Moodle is listed in the [[Installing_Moodle#Requirements|requirements section of the installation instructions]]&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.php.net/ The PHP home page]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/PHP Wikipedia article on PHP]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
&lt;br /&gt;
[[ja:PHP]]&lt;br /&gt;
[[pl:PHP]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Installing_Moodle&amp;diff=31016</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Installing_Moodle&amp;diff=31016"/>
		<updated>2008-01-07T19:58:25Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Firstly don&#039;t panic! :-)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This guide explains how to install Moodle for the first time. For some of these steps it goes into a lot of detail to try and cover the majority of possible web server setups, so this page may look long and complicated. Don&#039;t panic, once you know how to do it you can install Moodle in minutes!&lt;br /&gt;
&lt;br /&gt;
If you have problems please read this page carefully - most common issues are answered in here. If you still have trouble, you can seek help from the Moodle community via  [http://moodle.org/course/view.php?id=5 moodle.org Using Moodle].&lt;br /&gt;
&lt;br /&gt;
Another option is to contact a [http://moodle.com/hosting/ Moodle Partner providing Moodle hosting] who can completely maintain Moodle for you, so that you can ignore all this and get straight into educating! A Moodle partner is the preferred option but if you decide to choose a hosting company that has cpanel then [http://otaru-jc.ac.jp/hagley/settingupmoodleonhostingwithcpanel.swf this tutorial will guide you]  through the process of choosing a host and setting up moodle via cpanel. &lt;br /&gt;
&lt;br /&gt;
If you want to run Moodle on your own computer and this page looks a bit daunting, then please see our guides: [[Installing AMP |Installing Apache, MySQL and PHP(AMP)]] or [[Complete install packages| how to install one of Moodle&#039;s complete packages]]. They provide alternative instructions to install all this on most popular platforms.&lt;br /&gt;
==Table of Contents==&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[MySQL]] and [[PHP]] (also sometimes known as the LAMP platform), but is also regularly tested with Windows XP/2000/2003 (WAMP), Solaris 10 (Sparc and x64), Mac OS X and Netware 6 operating systems. Support for PostgreSQL, Oracle and Microsoft SQL Server is also available.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note if you are using a hosted account&#039;&#039;&#039;: Most web hosts support all of these requirements by default. You should contact your web host&#039;s support desk to check that this is the case &#039;&#039;&#039;before&#039;&#039;&#039; signing-up with them. It is especially important to ask about any PHP memory limits or MySQL question limits. If your prospective host does not provide a service which meets these requirements, or you are already signed up with them, ask them why and consider taking your business elsewhere if they do not change.&lt;br /&gt;
&lt;br /&gt;
The requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Hardware&#039;&#039;&#039; (unless you are using a hosted server). &lt;br /&gt;
* Disk space: 160MB free (min). You will require more free space to store your teaching materials.&lt;br /&gt;
* Memory: 256MB (min), 1GB (recommended). The general rule of thumb is that Moodle can support 50 &#039;&#039;concurrent&#039;&#039; users for every 1GB of RAM, but this will vary depending on your specific hardware and software combination. &lt;br /&gt;
&#039;&#039;&#039;Software&#039;&#039;&#039;&lt;br /&gt;
* Web server software. Most people use [[Apache]], but Moodle should work fine under any web server that supports [[PHP]], such as [[IIS]] on Windows platforms. PHP does impose requirements on versions of web servers, however these are complex and the general advice is to use the newest version possible of your chosen web server. &lt;br /&gt;
* PHP scripting language. (Please note that there have been issues installing Moodle with [http://www.php-accelerator.co.uk PHP-Accelerator]). There are currently two versions (or branches) of PHP available: PHP4 and PHP5 and the version requirements are listed below.&lt;br /&gt;
** For Moodle version 1.4 or later: PHP4 (version 4.1.0 or later) or PHP5 (version 5.1.0 or later) are supported.&lt;br /&gt;
** For Moodle version 1.6 or later: the PHP4 (version 4.3.0 or later) or PHP5 (version 5.1.0 or later) are supported. &lt;br /&gt;
** Future Moodle versions 2.0 or later will not support PHP4 and will require PHP5 (version 5.2.0 or later).&lt;br /&gt;
** PHP Settings&lt;br /&gt;
*** &#039;&#039;safe_mode&#039;&#039; needs to be OFF (check in your php.ini or Apache configuration file).&lt;br /&gt;
*** &#039;&#039;memory_limit&#039;&#039; should be at least 16M (32M is recommended for Moodle 1.7 and 40M for Moodle 1.8 or later). Large sites may need more than 128M. PHP 5.2.x requires higher memory_limit values than previous versions of PHP. 64bit operating systems require even more memory.&lt;br /&gt;
*** &#039;&#039;session.save_handler&#039;&#039; needs to be set to files. &lt;br /&gt;
** PHP Extensions and libraries&lt;br /&gt;
*** The mbstring extension is recommended for Moodle 1.6 or later.&lt;br /&gt;
*** The iconv extension is recommended for Moodle 1.6 or later.&lt;br /&gt;
*** [http://www.libgd.org/ GD library] and the [http://www.freetype.org/ FreeType 2] library and extensions are needed to be able to look at the dynamic graphs that the logs pages make.&lt;br /&gt;
*** The mysql extension is required if you are using the MySQL database. Note that in some Linux distributions (notably Red Hat) this is an optional installation.&lt;br /&gt;
*** The pgsql extension is required if you are using the PostgreSQL database.&lt;br /&gt;
*** The zlib extension is required for zip/unzip functionality.&lt;br /&gt;
*** The curl extension is recommended for Moodle 1.8 or later.&lt;br /&gt;
*** The tokenizer extension is recommended for Moodle 1.8 or later.&lt;br /&gt;
*** The curl and openssl extensions are required for the Moodle network functionality (Moodle 1.8 or later).&lt;br /&gt;
*** Other PHP extensions may be required to support optional Moodle functionality, especially external authentication and/or enrolment (e.g. LDAP extension for LDAP authentication and the sockets extension for Chat server).&lt;br /&gt;
* A working database server: [[MySQL]] or [[PostgreSQL]] are completely supported and recommended for use with any version of Moodle. Support for Microsoft SQL Server and Oracle has been added in Moodle 1.7. MySQL is &#039;&#039;the&#039;&#039; choice for many people because it is very popular, but there are some [[Arguments in favour of PostgreSQL|arguments in favour of PostgreSQL]], especially if you are planning a large deployment. &lt;br /&gt;
** For Moodle 1.5 or later, MySQL (version 3.23 or later) or PostgreSQL (7.4 or later). &lt;br /&gt;
** For Moodle 1.6 or later, MySQL (version 4.1.12 or later) or PostgreSQL (7.4 or later).&lt;br /&gt;
** For Moodle 1.7 or later, MySQL (version 4.1.12 or later), PostgreSQL (7.4 or later) or Microsoft SQL Server 2005 (version 9 or [http://moodle.org/mod/forum/discuss.php?d=59284 SQL Server Express 2005])&lt;br /&gt;
: MySQL Notes: For Moodle 1.6 or later, If you use latin languages only you can use MySQL 4.1.12. If you are using non-latin languages you require MySQL 4.1.16 or later. Currently the MySQL setting &amp;quot;strict mode&amp;quot; must be OFF (set to &amp;quot;&amp;quot; or &amp;quot;MYSQL40&amp;quot;) in the MySQL configuration file. &lt;br /&gt;
: PostgreSQL Notes: The minimum version of PostgreSQL is 7.4 and Moodle is widely used with 8.0 and 8.1.&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== How many users? ==&lt;br /&gt;
&lt;br /&gt;
In addition to the hardware and software requirements, you will also need to think about the capacity of your Moodle installation in terms of the number of users it can handle. There are two numbers to plan for:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Browsing users&#039;&#039;&#039;: the maximum number of users able to browse your Moodle site. This is the number of computers in your organization or on your course (whichever is greater).&lt;br /&gt;
* &#039;&#039;&#039;Concurrent database users&#039;&#039;&#039;: the maximum number of concurrent database users (needed for Moodle activities such as quizzes). This is the number of users who will be using Moodle at the same time. In an educational institution, use your timetable/roster to obtain this figure.&lt;br /&gt;
&lt;br /&gt;
Once you know these figures for your users, you can start work out if your Moodle installation can support this capacity. The exact number of users depends on your hardware/software/network combination. Usually the amount of memory installed (RAM) is the deciding factor but a faster overall processor speed will also help in reducing waiting times for pages to load. &lt;br /&gt;
&lt;br /&gt;
The general rule of thumb for a single server is that the approx max concurrent users = RAM (GB) * 50 and the approx max browsing users = Approx max concurrent users * 5. As an example, a university with 500 total computers on campus and 100 concurrent users at any time will need approx 2GB of RAM on the one server to support the number of concurrent users.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note if you are using a hosted account&#039;&#039;&#039;: Ask your provider what limits are placed on the number of concurrent database connections and the processor load. This will give a good estimate of the number of users your Moodle install can manage.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; As of August 31, 2007, the moodle 1.8.2+ codes are still not suitable for large installation, especially if you have large number (e.g. 20,000+) of courses. The main reason is the codes related to ROLES are still not fully optimized with database queries and still need some work. If you are planning to use 1.8.x codes for a larger institution, please make sure that you have sufficient time to do your own testing and performance profiling.&lt;br /&gt;
&lt;br /&gt;
[Update] This performance issue has been improved quite a bit in the most recent 1.8.3+ version (see this thread discussion: http://moodle.org/mod/forum/discuss.php?d=83281). However, you should still plan with caution if you are planning to use Moodle 1.8.x code base for larger installation.&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
There are two ways to get Moodle, either as a compressed package or via CVS. &lt;br /&gt;
* There are two types of compressed packages on the  [http://download.moodle.org/ download page: http://download.moodle.org/], the standard distribution with Moodle only files and the [[Complete install packages|complete install]], which contains programs to operate Moodle in a web environment.  &lt;br /&gt;
* To use CVS, helpful instructions are available at the [[CVS_for_Administrators | CVS for Administrators]] page. The full [http://cvs.moodle.org/moodle/ Moodle CVS repository] is also available for browsing. &lt;br /&gt;
&lt;br /&gt;
After downloading, unpack the archive using either &lt;br /&gt;
 tar -zxvf [filename]&lt;br /&gt;
or&lt;br /&gt;
 unzip [filename]&lt;br /&gt;
as appropriate. &lt;br /&gt;
&lt;br /&gt;
If using CVS, run the CVS Checkout command.&lt;br /&gt;
&lt;br /&gt;
You will now be left with a directory called &amp;quot;moodle&amp;quot;, containing a number of files and folders.&lt;br /&gt;
&lt;br /&gt;
You can either place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If you are downloading Moodle to your local computer and then uploading it to your web site, it is usually better to upload the whole archive as one file, and then do the unpacking on the server. Even web hosting interfaces like cPanel allow you to uncompress archives in the &amp;quot;File Manager&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Structure of moodle directory ===&lt;br /&gt;
&lt;br /&gt;
You can safely skip this section, but here is a quick summary of the contents of the Moodle folder, to help get you oriented:&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;config.php&#039;&#039; - contains basic settings. This file does not come with Moodle - you will create it.&lt;br /&gt;
:&#039;&#039;install.php&#039;&#039; - the script you will run to create config.php&lt;br /&gt;
:&#039;&#039;version.php&#039;&#039; - defines the current version of Moodle code&lt;br /&gt;
:&#039;&#039;index.php&#039;&#039; - the front page of the site&lt;br /&gt;
:&#039;&#039;admin/&#039;&#039; - code to administrate the whole server&lt;br /&gt;
:&#039;&#039;auth/&#039;&#039; - plugin modules to authenticate users&lt;br /&gt;
:&#039;&#039;blocks/&#039;&#039; - plugin modules for the little side blocks on many pages&lt;br /&gt;
:&#039;&#039;calendar/&#039;&#039; - all the code for managing and displaying calendars&lt;br /&gt;
:&#039;&#039;course/&#039;&#039; - code to display and manage courses&lt;br /&gt;
:&#039;&#039;doc/&#039;&#039; - help documentation for Moodle (eg this page)&lt;br /&gt;
:&#039;&#039;files/&#039;&#039; - code to display and manage uploaded files&lt;br /&gt;
:&#039;&#039;lang/&#039;&#039; - texts in different languages, one directory per language&lt;br /&gt;
:&#039;&#039;lib/&#039;&#039; - libraries of core Moodle code&lt;br /&gt;
:&#039;&#039;login/&#039;&#039; - code to handle login and account creation&lt;br /&gt;
:&#039;&#039;mod/&#039;&#039; - all the main Moodle course modules are in here&lt;br /&gt;
:&#039;&#039;pix/&#039;&#039; - generic site graphics&lt;br /&gt;
:&#039;&#039;theme/&#039;&#039; - theme packs/skins to change the look of the site.&lt;br /&gt;
:&#039;&#039;user/&#039;&#039; - code to display and manage users&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Setting-up your system==&lt;br /&gt;
To ensure that Moodle will install successfully, you need to check that the web server settings are correct, then create a blank database for Moodle to use and finally create a directory on your hard disk for Moodle to save your materials and other files you upload into your courses.&lt;br /&gt;
&lt;br /&gt;
=== Check web server settings ===&lt;br /&gt;
&lt;br /&gt;
*Firstly, make sure that your web server is set up to use index.php as a default page (perhaps in addition to index.html, default.htm and so on). In Apache, this is done using a DirectoryIndex parameter in your httpd.conf file. Mine usually looks like this:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;DirectoryIndex&#039;&#039;&#039; index.php index.html index.htm&lt;br /&gt;
&lt;br /&gt;
:Just make sure index.php is in the list (and preferably towards the start of the list, for efficiency).&lt;br /&gt;
&lt;br /&gt;
*Secondly, &#039;&#039;&#039;if you are using Apache 2&#039;&#039;&#039;, then you should turn on the &#039;&#039;AcceptPathInfo&#039;&#039; variable, which allows scripts to be passed arguments like &amp;lt;nowiki&amp;gt;http://server/file.php/arg1/arg2&amp;lt;/nowiki&amp;gt;. This is essential to allow relative links between your resources, and also provides a performance boost for people using your Moodle web site. You can turn this on by adding these lines to your httpd.conf file.&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;AcceptPathInfo&#039;&#039;&#039; on&lt;br /&gt;
&lt;br /&gt;
=== Check PHP settings ===&lt;br /&gt;
Moodle requires a number of PHP settings to be active for it to work. &#039;&#039;&#039;On most servers these will already be the default settings&#039;&#039;&#039;.  However, some PHP servers (and some of the more recent PHP versions) may have things set differently. These are defined in PHP&#039;s configuration file (usually called &#039;&#039;&#039;php.ini&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 magic_quotes_gpc = 1    (preferred but not necessary)&lt;br /&gt;
 magic_quotes_runtime = 0    (necessary)&lt;br /&gt;
 file_uploads = 1&lt;br /&gt;
 session.auto_start = 0&lt;br /&gt;
 session.bug_compat_warn = 0&lt;br /&gt;
&lt;br /&gt;
:You may also want to set other, optional php.ini file settings while you are already editing it. For instance, you may want to reset the maximum upload size of file attachments, which usually defaults to 2M(egabytes). For instance, to set these to 16 Megabytes:&lt;br /&gt;
 &lt;br /&gt;
 post_max_size = 16M&lt;br /&gt;
 upload_max_filesize = 16M&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
=== Using a .htaccess file for webserver and PHP settings ===&lt;br /&gt;
&lt;br /&gt;
Use the above if you can directly edit your server&#039;s files, but if you are setting-up Moodle on a webhost, or don&#039;t have access to &#039;&#039;&#039;httpd.conf&#039;&#039;&#039; or &#039;&#039;&#039;php.ini&#039;&#039;&#039; on your server, or you have Moodle on a server with other applications that require different settings, then don&#039;t worry, you can often still override the default settings. This only works on Apache servers and only when Overrides have been allowed in the main Apache configuration.&lt;br /&gt;
&lt;br /&gt;
* Create a file called &#039;&#039;&#039;.htaccess&#039;&#039;&#039; in Moodle&#039;s main directory that contains lines like the following. &lt;br /&gt;
&lt;br /&gt;
 DirectoryIndex index.php index.html index.htm&lt;br /&gt;
 php_flag magic_quotes_gpc 1&lt;br /&gt;
 php_flag magic_quotes_runtime 0&lt;br /&gt;
 php_flag file_uploads 1&lt;br /&gt;
 php_flag session.auto_start 0&lt;br /&gt;
 php_flag session.bug_compat_warn 0&lt;br /&gt;
&lt;br /&gt;
:If you have Apache version 2 installed, add these lines:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;IfDefine APACHE2&amp;gt;&lt;br /&gt;
     AcceptPathInfo on&lt;br /&gt;
 &amp;lt;/IfDefine&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:Otherwise add this single line:&lt;br /&gt;
&lt;br /&gt;
 AcceptPathInfo on&lt;br /&gt;
&lt;br /&gt;
* Optionally, you can also do things like define the maximum size for uploaded files, etc by adding these lines:&lt;br /&gt;
&lt;br /&gt;
 LimitRequestBody 0&lt;br /&gt;
 php_value upload_max_filesize 2M&lt;br /&gt;
 php_value post_max_size 2M&lt;br /&gt;
     &lt;br /&gt;
* The easiest thing to do is just copy the sample file from lib/htaccess and edit it to suit your needs. It contains further instructions. For example, in a Unix shell:&lt;br /&gt;
&lt;br /&gt;
 cp lib/htaccess .htaccess&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Use a .htaccess file only [http://httpd.apache.org/docs/1.3/howto/htaccess.html#when as a last resort] as it can have an impact on the performance of your Moodle site and cause pages to load slowly on your browser.&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
=== Creating an empty database ===&lt;br /&gt;
&lt;br /&gt;
You need to create an empty database (eg &amp;quot;&#039;&#039;moodle&#039;&#039;&amp;quot;) in your database system along with a special user (eg &amp;quot;moodleuser&amp;quot;) that has access to that database (and that database only). You could use the &amp;quot;root&amp;quot; user if you wanted to for a test server, but this is not recommended for a production system: if hackers manage to discover the password then your whole database system would be at risk, rather than just one database.&lt;br /&gt;
&lt;br /&gt;
::&#039;&#039;&#039;Warning&#039;&#039;&#039;: Bear in mind that, as of Moodle version 1.5.x, Moodle doesn&#039;t work with MySQL 5.x&#039;s strict mode setting (STRICT_TRANS_TABLES and/or STRICT_ALL_TABLES) -- see [http://moodle.org/mod/forum/discuss.php?d=58552 forum discussion]. So if you are using MySQL 5.x, edit MySQL&#039;s configuration file (called &amp;quot;my.ini&amp;quot; in Windows and &amp;quot;my.cnf&amp;quot; on Unix/Linux) and comment out that option or set it to &amp;lt;code&amp;gt;sql-mode=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. You have to restart MySQL after changing this setting. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; If you do not have access to your server, use PHPMyAdmin (or another MySQL client) and enter the command &amp;lt;code&amp;gt;SET @@global.sql_mode=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;;&amp;lt;/code&amp;gt; (be sure to use single quotes, and don&#039;t forget the semicolon).&lt;br /&gt;
&lt;br /&gt;
====Using a hosted server====&lt;br /&gt;
If you are using a webhost, they will probably have a control panel web interface for you to create your database.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[http://www.cpanel.com/ cPanel]&#039;&#039;&#039; system is one of the most popular of these. To create a database in cPanel,&lt;br /&gt;
&lt;br /&gt;
# Click on the &amp;quot;&#039;&#039;&#039;MySQL Databases&#039;&#039;&#039;&amp;quot; icon.&lt;br /&gt;
# Type &amp;quot;moodle&amp;quot; in the database field and click &amp;quot;&#039;&#039;&#039;Add Database&#039;&#039;&#039;&amp;quot;.&lt;br /&gt;
# Type a username and password (not one you use elsewhere) in the respective fields and click &amp;quot;&#039;&#039;&#039;Add User&#039;&#039;&#039;&amp;quot;.&lt;br /&gt;
# Now use the &amp;quot;&#039;&#039;&#039;Add User to Database&#039;&#039;&#039;&amp;quot; button to give this new user account &amp;quot;&#039;&#039;&#039;ALL&#039;&#039;&#039;&amp;quot; rights to the new database.&lt;br /&gt;
# Note that the username and database names may be prefixed by your cPanel account name. When entering this information into the Moodle installer - use the full names.&lt;br /&gt;
&lt;br /&gt;
====Using the command line====&lt;br /&gt;
&lt;br /&gt;
If you have access to Unix or Windows command lines then you can do the same sort of thing by typing commands. You should do this using the MySQL Client program as follows (commands which you type-in are shown in bold):&lt;br /&gt;
&lt;br /&gt;
- Start the MySQL Client program:&lt;br /&gt;
 #&#039;&#039;&#039;mysql -u root -p&#039;&#039;&#039;&lt;br /&gt;
 Enter password:&lt;br /&gt;
 Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;
 Your MySQL connection id is 2 to server version: 5.0.22-log&lt;br /&gt;
 &lt;br /&gt;
 Type &#039;help;&#039; or &#039;\h&#039; for help. Type &#039;\c&#039; to clear the buffer.&lt;br /&gt;
 &lt;br /&gt;
 mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The prompt changes to &amp;quot;mysql&amp;gt;&amp;quot; to indicate that you are now working in the MySQL Client program. When working in MySQL, all commands which you type-in must end in a semi-colon. (If you hit the Enter key without the final semi-colon, you&#039;ll get the line continuation symbol &#039;-&amp;gt;&#039;; this is your second chance to type the semi-colon and hit Enter.) &lt;br /&gt;
&lt;br /&gt;
- Begin by checking for any existing databases called &amp;quot;moodle&amp;quot; - if there are any you should change the name in all the commands which follow:&lt;br /&gt;
 mysql&amp;gt; &#039;&#039;&#039;SHOW DATABASES;&#039;&#039;&#039;&lt;br /&gt;
 +-------------------------+&lt;br /&gt;
 | Database                |&lt;br /&gt;
 +-------------------------+&lt;br /&gt;
 | information_schema      |&lt;br /&gt;
 | mysql                   |&lt;br /&gt;
 | test                    |&lt;br /&gt;
 +-------------------------+&lt;br /&gt;
 3 rows in set (0.03 sec)&lt;br /&gt;
&lt;br /&gt;
- Create a database to store the Moodle tables. We&#039;ll call this &amp;quot;moodle&amp;quot;, as there are none with that name already in the above list, but change it if you need to.&lt;br /&gt;
 mysql&amp;gt; &#039;&#039;&#039;CREATE DATABASE moodle;&#039;&#039;&#039;&lt;br /&gt;
 Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
- Change the default character set and collation of the &amp;quot;moodle&amp;quot; database to UTF8. Leave this out if you are installing Moodle 1.5 or earlier):&lt;br /&gt;
 mysql&amp;gt; &#039;&#039;&#039;ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;&#039;&#039;&#039;&lt;br /&gt;
 Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
- Create a username and password to access the database &amp;quot;moodle&amp;quot; and grant database access permissions. We&#039;ll call the user &amp;quot;moodleuser&amp;quot; and set the password as &amp;quot;yourpassword&amp;quot;. It&#039;s a good idea to change these for your installation however most people keep the username as &amp;quot;moodleuser&amp;quot;. Remember the username and password you have set, as you&#039;ll need it in the configuration screens later. This is a long command so has been split over several lines by pressing the Return key.&lt;br /&gt;
 mysql&amp;gt; &#039;&#039;&#039;GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,&#039;&#039;&#039;&lt;br /&gt;
     -&amp;gt; &#039;&#039;&#039;DROP,INDEX,ALTER ON moodle.*&#039;&#039;&#039;&lt;br /&gt;
     -&amp;gt; &#039;&#039;&#039;TO moodleuser@localhost IDENTIFIED BY &#039;yourpassword&#039;;&#039;&#039;&#039;&lt;br /&gt;
 Query OK, 0 rows affected (0.01 sec)&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Security Warnings&#039;&#039;&#039;: Never leave the password as the one shown here. Make sure you have a strong password (a mixture of letters and numbers, upper and lower case). Avoid granting &amp;quot;ALL&amp;quot; permissions on the database.&lt;br /&gt;
: &#039;&#039;&#039;Note&#039;&#039;&#039;: For MySQL 4.0.1 or earlier, you don&#039;t need the CREATE TEMPORARY TABLES permission. &lt;br /&gt;
&lt;br /&gt;
- Exit the MySQL Client program:&lt;br /&gt;
 mysql&amp;gt; &#039;&#039;&#039;QUIT&#039;&#039;&#039;&lt;br /&gt;
 Bye&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
- Reload the grant tables using the mysqladmin program:&lt;br /&gt;
 #&#039;&#039;&#039;mysqladmin -u root -p reload&#039;&#039;&#039;&lt;br /&gt;
 Enter password:&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
And some example command lines for PostgreSQL:&lt;br /&gt;
&lt;br /&gt;
   # su - postgres&lt;br /&gt;
   &amp;gt; psql -c &amp;quot;create user moodleuser createdb;&amp;quot; template1&lt;br /&gt;
   &amp;gt; psql -c &amp;quot;create database moodle &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;with encoding &#039;unicode&#039;&amp;lt;/font&amp;gt;;&amp;quot; -U moodleuser template1&lt;br /&gt;
   &amp;gt; psql -c &amp;quot;alter user moodleuser nocreatedb;&amp;quot; template1&lt;br /&gt;
   &amp;gt; psql -c &amp;quot;alter user moodleuser with encrypted password &#039;yourpassword&#039;;&amp;quot; template1&lt;br /&gt;
   &amp;gt; su - root&lt;br /&gt;
   # /etc/init.d/postgresql reload&lt;br /&gt;
&lt;br /&gt;
If the Postgres create database command above (&amp;gt;psql -c &amp;quot;create database moodle...&amp;quot;) gives an error message you may want to try:&lt;br /&gt;
 psql -c &amp;quot;create database moodle with template=template1 encoding = &#039;unicode&#039; owner =  moodleuser &amp;lt;br&amp;gt;     location = &#039;/var/mydata&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If the create database command asks you for a password, run the line containing &#039;encrypted password&#039; first before proceeding.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See also&#039;&#039;&#039;:&lt;br /&gt;
* Step-by-step instructions on  [https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Ubuntu installation for Ubuntu(Debian)]&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
=== Creating the data directory (moodledata) ===&lt;br /&gt;
&lt;br /&gt;
Moodle will also need some space on your server&#039;s hard disk to store uploaded files, such as course documents and user pictures. The Moodle installer tries hard to create this directory for you but if it fails then you will have to create a directory for this purpose manually.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Security warning&#039;&#039;&#039;: For security purposes, it&#039;s best that this directory is NOT accessible directly via the web. The easiest way to do this is to simply locate it OUTSIDE the web directory, but if you must have it in the web directory (and you are using Apache) then protect it by creating a file in the data directory called &#039;&#039;&#039;.htaccess&#039;&#039;&#039;, containing these lines:&lt;br /&gt;
&lt;br /&gt;
 order deny,allow&lt;br /&gt;
 deny from all&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ownership &amp;amp; Permissions&#039;&#039;&#039;: To make sure that Moodle can save uploaded files in this directory, check that the web server software has permission to read, write and execute in this directory. On Unix machines, this means setting the owner of the directory to be something like &amp;quot;nobody&amp;quot; or &amp;quot;apache&amp;quot;, and then giving that user read, write and execute permissions. As an example, to change the owner to &amp;quot;nobody&amp;quot; you could use:&lt;br /&gt;
&lt;br /&gt;
 chown -R nobody:apache moodledata&lt;br /&gt;
&lt;br /&gt;
To change the permissions so that the owner has read,write and execute permissions, use something like this:&lt;br /&gt;
&lt;br /&gt;
 chmod -R 0770 moodledata&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: If you are receiving permission denied messages, try &#039;&#039;chmod -R 0770 moodledata&#039;&#039; and then adjust the settings so that they are more secure. A more secure setting is &#039;&#039;chmod -R 0750 moodledata&#039;&#039;. According to the comments in config-dist.php, &amp;quot;On hosting systems you might need to make sure that your group has no permissions at all while others have full permissions.&amp;quot; To do this you could use &#039;&#039;chmod -R 707 moodledata&#039;&#039;. See also the [[Security | security page]].&lt;br /&gt;
&lt;br /&gt;
Remember that by default moodle will issue a warning about moodle data directories created inside the web directory, but otherwise this directory can be located where you wish. You can later move or change the location of this directory, but if you do, be sure to edit the setting in the &#039;&#039;&#039;config.php&#039;&#039;&#039; file that sets this; e.g. if moodledata is under a directory called data, then it would look like this:&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;dataroot  = &#039;/data/moodledata&#039;;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CPanel and webhosts&#039;&#039;&#039;: On cPanel systems you can use the &amp;quot;File Manager&amp;quot; to find the folder, click on it, then choose &amp;quot;Change Permissions&amp;quot;. On many shared hosting servers, you will probably need to restrict all file access to your &amp;quot;group&amp;quot; (to prevent other webhost customers from looking at or changing your files), but provide full read/write access to everyone else (which will allow the web server to access your files). Speak to your server administrator if you are having trouble setting this up securely. In particular it will not be possible to create a usable data directory on sites that use a PHP feature known as &amp;quot;&#039;&#039;&#039;Safe Mode&#039;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Run the installer script to create config.php ==&lt;br /&gt;
&lt;br /&gt;
To run the installer script (install.php), just try to access your Moodle main URL using a web browser, or access &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourserver/install.php&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; directly.&lt;br /&gt;
&lt;br /&gt;
(The Installer will try to set a session cookie. If you get a popup warning in your browser make sure you accept that cookie!)&lt;br /&gt;
&lt;br /&gt;
Moodle will detect that configuration is necessary and will lead you through some screens to help you create a new configuration file called &#039;&#039;&#039;config.php&#039;&#039;&#039;. At the end of the process Moodle will try and write the file into the right location, otherwise you can press a button to download it from the installer and then upload &#039;&#039;&#039;config.php&#039;&#039;&#039; into the main Moodle directory on the server.&lt;br /&gt;
&lt;br /&gt;
Along the way the installer will test your server environment and give you suggestions about how to fix any problems. For most common issues these suggestions should be sufficient, but if you get stuck, check in the Installation Forum for more help.&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Go to the admin page to continue configuration ==&lt;br /&gt;
&lt;br /&gt;
Once the basic config.php has been correctly created in the previous step, trying to access the front page of your site will take you to the &amp;quot;admin&amp;quot; page for the rest of the configuration.&lt;br /&gt;
&lt;br /&gt;
The first time you access this admin page, you will be presented with a GPL &amp;quot;shrink wrap&amp;quot; agreement with which you must agree before you can continue with the setup.&lt;br /&gt;
&lt;br /&gt;
Now Moodle will start setting up your database and creating tables to store data. Firstly, the main database tables are created. You should see a number of SQL statements followed by status messages that look like this:&lt;br /&gt;
&lt;br /&gt;
 CREATE TABLE course (&lt;br /&gt;
    id int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
    category int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
    password varchar(50) NOT NULL default &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;,&lt;br /&gt;
    fullname varchar(254) NOT NULL default &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;,&lt;br /&gt;
    shortname varchar(15) NOT NULL default &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;,&lt;br /&gt;
    summary text NOT NULL,&lt;br /&gt;
    format tinyint(4) NOT NULL default &#039;1&#039;,&lt;br /&gt;
    teacher varchar(100) NOT NULL default &#039;Teacher&#039;,&lt;br /&gt;
    startdate int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
    enddate int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
    timemodified int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
    PRIMARY KEY (id)&lt;br /&gt;
 ) TYPE=MyISAM;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;font color=&amp;quot;green&amp;quot;&amp;gt;SUCCESS&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...and so on, followed by: &amp;lt;font color=&amp;quot;green&amp;quot;&amp;gt;Main databases set up successfully.&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t see these, then there must have been some problem with the database or the configuration settings you defined in config.php. Check that PHP isn&#039;t in a restricted &amp;quot;Safe Mode&amp;quot; (commercial web hosts sometimes have safe mode turned on). You can check PHP variables by creating a little file containing &#039;&#039;&#039;&amp;lt;?php phpinfo() ?&amp;gt;&#039;&#039;&#039; and looking at it through a browser. Check all these and try this page again.&lt;br /&gt;
&lt;br /&gt;
Scroll down the very bottom of the page and press the &amp;quot;Continue&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You should now see a form where you can define more configuration variables for your installation, such as the default language, SMTP hosts and so on. Don&#039;t worry too much about getting everything right just now - you can always come back and edit these later on using the admin interface. The defaults are designed to be useful and secure for most sites. Scroll down to the bottom and click &amp;quot;Save changes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If (and only if) you find yourself getting stuck on this page, unable to continue, then your server probably has what I call the &amp;quot;buggy referrer&amp;quot; problem. This is easy to fix: just turn off the &amp;quot;secureforms&amp;quot; setting, then try to continue again.&lt;br /&gt;
&lt;br /&gt;
Next you will see more pages that print lots of status messages as they set up all the tables required by the various Moodle module. As before, they should all be &amp;lt;font color=&amp;quot;green&amp;quot;&amp;gt;green&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Scroll down the very bottom of the page and press the &amp;quot;Continue&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
The next page is a form where you can define parameters for your Moodle site and the front page, such as the name, format, description and so on. Fill this out (you can always come back and change these later) and then press &amp;quot;Save changes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Finally, you will then be asked to create a top-level administration user for future access to the admin pages. Fill out the details with your own name, email etc and then click &amp;quot;Save changes&amp;quot;. Not all the fields are required, but if you miss any important fields you&#039;ll be re-prompted for them.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Make sure you remember the username and password you chose for the administration user account, as they will be necessary to access the administration page in future.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(If for any reason your install is interrupted, or there is a system error of some kind that prevents you from logging in using the admin account, you can usually log in using the default username of &amp;quot;&#039;&#039;&#039;admin&#039;&#039;&#039;&amp;quot;, with password &amp;quot;&#039;&#039;&#039;admin&#039;&#039;&#039;&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
Once successful, you will be returned to the home page of your new site! Note the administration links that appear down the left hand side of the page (these items also appear on a separate Admin page) - these items are only visible to you because you are logged in as the admin user. All your further administration of Moodle can now be done using this menu, such as:&lt;br /&gt;
&lt;br /&gt;
* creating and deleting courses&lt;br /&gt;
* creating and editing user accounts&lt;br /&gt;
* administering teacher accounts&lt;br /&gt;
* changing site-wide settings like themes etc&lt;br /&gt;
&lt;br /&gt;
But you are not done installing yet! There is one very important thing still to do (see the next section on cron).&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Set up cron ==&lt;br /&gt;
&lt;br /&gt;
Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
&lt;br /&gt;
== Set up backups ==&lt;br /&gt;
&lt;br /&gt;
Please refer to the [[Backup settings| backup instructions]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Installing_Moodle#Table_of_Contents|Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
== Create a new course ==&lt;br /&gt;
&lt;br /&gt;
Now that Moodle is running properly, you can try creating a new course to play with.&lt;br /&gt;
&lt;br /&gt;
Select &amp;quot;Create a new course&amp;quot; from the Admin page (or the admin links on the home page).&lt;br /&gt;
&lt;br /&gt;
Fill out the form, paying special attention to the course format. You don&#039;t have to worry about the details too much at this stage, as everything can be changed later by the teacher. Note that the yellow help icons are everywhere to provide contextual help on any aspect.&lt;br /&gt;
&lt;br /&gt;
Press &amp;quot;Save changes&amp;quot;, and you will be taken to a new form where you can assign teachers to the course. You can only add existing user accounts from this form - if you want to create a new teacher account then either ask the teacher to create one for themselves (see the login page), or create one for them using the &amp;quot;Add a new user&amp;quot; on the Admin page.&lt;br /&gt;
&lt;br /&gt;
Once done, the course is ready to customize, and is accessible via the &amp;quot;Courses&amp;quot; link on the home page.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Installation FAQ]]&lt;br /&gt;
*[[Complete install packages]] might be an easier first time installs on some systems&lt;br /&gt;
* [[Installing Apache, MySQL and PHP]] - Open source programs that can run Moodle on the web or on a desktop&lt;br /&gt;
* [[Upgrading Moodle]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=42688 Selecting a web host for Moodle] forum discussion&lt;br /&gt;
* [[masquerading|Masquerading]] - Running Moodle behind a masquerading/NAT firewall&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[cs:Instalace]]&lt;br /&gt;
[[de:Installieren von Moodle]]&lt;br /&gt;
[[es:Instalación de moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;br /&gt;
[[nl:Installatiegids]]&lt;br /&gt;
[[ru:Установка Moodle]]&lt;br /&gt;
[[sk:Inštalácia]]&lt;br /&gt;
[[zh:安装Moodlezh:]]&lt;br /&gt;
[[pl:Instalacja Moodle]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Installing_AMP&amp;diff=30914</id>
		<title>Installing AMP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Installing_AMP&amp;diff=30914"/>
		<updated>2008-01-06T12:58:44Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AMP or AMPPlite stands for &#039;&#039;&#039;A&#039;&#039;&#039;pache, &#039;&#039;&#039;M&#039;&#039;&#039;ySQL &amp;amp; &#039;&#039;&#039;P&#039;&#039;&#039;HP.  Moodle is written in a scripting language called [[PHP]] and stores most of its data in a database. The recommended database is [[MySQL]]. Before installing Moodle you must have a working PHP installation and a working database to turn your computer into a functional web server platform. XAMP is a Windows and MAMP is a Mac OS version. &lt;br /&gt;
Moodle does have [[Complete install packages]] in the [http://download.moodle.org/ download section] as well as the Moodle only package.&lt;br /&gt;
&lt;br /&gt;
The AMP individual applications can be tricky to set up for average computer users.  This page has been written to try to make this process as simple as possible for different platforms.     &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Hosting Service ==&lt;br /&gt;
&lt;br /&gt;
Unfortunately hosting services vary quite a lot in the way they work. Some will even install Moodle for you.&lt;br /&gt;
&lt;br /&gt;
Most will offer a web-based control panel to control your site, create databases and set up cron. Some may also offer terminal access via ssh, so that you can use the command shell to do things.&lt;br /&gt;
&lt;br /&gt;
You should work your way through the [[Installing Moodle|Installation guide]] and take each step at a time. Ask your hosting provider if you get stuck.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mac OS X ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to do this is use the [[Apache]] server that Apple provides, and add PHP and MySQL using Marc Liyanage&#039;s packages. Both of the pages below come with good instructions that we won&#039;t duplicate here:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;PHP&#039;&#039;&#039;: Download from here: http://www.entropy.ch/software/macosx/php/&lt;br /&gt;
* &#039;&#039;&#039;MySQL&#039;&#039;&#039;: Download here: http://www.entropy.ch/software/macosx/mysql/&lt;br /&gt;
&lt;br /&gt;
Once these are installed the standard [[Installing Moodle|Installation guide]] should be fairly straightforward.&lt;br /&gt;
&lt;br /&gt;
Go here for a [[Step-by-step Guide for Installing Moodle on Mac OS X 10.4 Client]] (not server) Mac.&lt;br /&gt;
&lt;br /&gt;
== Red Hat Linux ==&lt;br /&gt;
&lt;br /&gt;
You should install all available RPM packages for Apache, PHP and MySQL. One package that people frequently forget is the php-mysql package which is necessary for PHP to talk to MySQL.&lt;br /&gt;
&lt;br /&gt;
Once these are installed the standard [[Installing Moodle|Installation guide]] should be fairly straightforward.&lt;br /&gt;
&lt;br /&gt;
A more detailed walkthrough is here: [[RedHat Linux installation]]&lt;br /&gt;
&lt;br /&gt;
== Windows ==&lt;br /&gt;
&lt;br /&gt;
Installing Moodle &#039;&#039;&#039;for the first time&#039;&#039;&#039; on a [[Localhost]] (a stand alone computer) is easy and can be a very useful tool even if a web based production Moodle Server is available for use. These instructions work on a Windows XP computer.&lt;br /&gt;
#On the [http://download.moodle.org/windows/ Windows packages] download page, choose the version you would like. Click on the download link in the rightmost column. This will download a large zip file.&lt;br /&gt;
#Unzip the downloaded file at c: and keep the path structure for all the files.   &lt;br /&gt;
#Rename the just created c:\moodle to c:\xampplite (c:\xampplite will be our example) but you could rename it c:\moodle16 or c:\moodle17 or C:\testMoodle or whatever .&lt;br /&gt;
#Using Windows Explorer run the file c:\xampplite\setup_xampp.bat which will make sure all the configuration files use c:\xampplite as the home or root directory.&lt;br /&gt;
#The following steps assume that the web server will be able to use port 80 on your computer. See [[Windows_installation_using_XAMPP#Skype |troubleshooting if you are running Skype]] which also likes to use this port as a default. &lt;br /&gt;
#Be sure that you are administrator or at least that you have rights to install new services.&lt;br /&gt;
#There many ways to start the localhost webserver from this point for the Moodle install.  Here are two ways.&lt;br /&gt;
##Slightly faster&lt;br /&gt;
###Using Windows Explorer run the file c:\xampplite\restart_xampp.bat and do not close the window that opens.&lt;br /&gt;
##Still fast&lt;br /&gt;
###In Windows Explorer click on  c:\xampplite\apache_start to start the Apache web server. This opens a new window that you should leave open.&lt;br /&gt;
###In Windows Explorer click on  c:\xampplite\mysql_start to start the MySQL database server. This opens yet another new window that you should leave open.&lt;br /&gt;
#In your favorite Web browser, go to the address bar and type &amp;quot;localhost&amp;quot; or &amp;quot;127.0.0.1&amp;quot; and press enter or click go.&lt;br /&gt;
#This will start the Moodle Install process, which the [[Installing Moodle]] [[Installing_Moodle#Go_to_the_admin_page_to_continue_configuration| MoodleDoc page section]] describes in a little bit more detail. This can take some time for a new user. &#039;&#039;&#039;Don&#039;t panic&#039;&#039;&#039;, you can change things later and the install process will tell you what you absolutely have to fill in or correct.&lt;br /&gt;
&lt;br /&gt;
===Easier Moodle restarts===&lt;br /&gt;
There are lots of ways to start a Moodle after an install.   Most Moodlers will have one or more &amp;quot;localhost&amp;quot; links on their computer installed in &amp;quot;Favorites&amp;quot; or even as a browser&#039;s default opening screen. But first a web server has to be started. Here are two ways to start them.  &lt;br /&gt;
====Automatic Windows services startup====&lt;br /&gt;
In order to make starting Moodle more convenient in the future you could install the web  and database servers as Windows services that are started automatically. To do this go to Start -&amp;gt; Run... and type the command &amp;quot;c:/xampplite/service.exe -install&amp;quot; into Open box. Then click OK.&lt;br /&gt;
&lt;br /&gt;
Start Moodle by typing localhost in the web browser and/or adding localhost as a favorite site.&lt;br /&gt;
====Single button service startups====&lt;br /&gt;
Sometimes there are more than one localhost installed on a computer. Create a shortcut on the start menu, favorites or desktop that points to each specific file like c:\xampplite\restart_xampp.bat . Label each shortcut to a localhost differently, for example C_MoodleXampp, or Moodle16 or Moodle17 or whatever.   &lt;br /&gt;
&lt;br /&gt;
Start Moodle by placing localhost in the web browser or adding it as a favorite site. Whichever localhost you restarted, that is the Moodle your web browser will find.&lt;br /&gt;
&lt;br /&gt;
==Other install options==&lt;br /&gt;
Instead of using this package you can also install XAMPP and Moodle separately as explained on the page [[Windows_installation_using_XAMPP]]. &lt;br /&gt;
&lt;br /&gt;
As an alternative to the above package you could use a package like EasyPHP that bundles all the software you need into a single Windows application.  Note that the EasyPHP 1.8 uses older versions of the software that are too old for Moodle 1.6.  Also many menus for EasyPHP are still in French. EasyPHP may be a good option again once its version 2.0 is released.&lt;br /&gt;
&lt;br /&gt;
Here you can find steps for an [[IIS]]: [[Windows installation]] for XAMPP or Windows 2003 .&lt;br /&gt;
&lt;br /&gt;
==Testing PHP==&lt;br /&gt;
Once you have installed your web server and PHP you should be able to create a file (for example phpinfo.php in the document root) with the following in it:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;?php phpinfo()?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be able to open this file in a web browser by going to to the URL &#039;&#039;&#039;localhost/phpinfo&#039;&#039;&#039; and see a web page that has PHP status information in it such as [[phpinfo|this]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Installing Moodle]]&lt;br /&gt;
*[[Installation FAQ]]&lt;br /&gt;
*[[Upgrading Moodle]]&lt;br /&gt;
*[[Debian GNU/Linux installation]]&lt;br /&gt;
*[[Complete install packages]], also includes instructions for creating a stand alone (localhost) installation on a single computer.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[es:Instalación AMP]]&lt;br /&gt;
[[fr:Installation de AMP]]&lt;br /&gt;
[[ja:AMPのインストール]]&lt;br /&gt;
[[ru:Установка AMP]]&lt;br /&gt;
[[pl:Instalacja AMP]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Category:Installation&amp;diff=30913</id>
		<title>Category:Installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Category:Installation&amp;diff=30913"/>
		<updated>2008-01-06T12:57:56Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to pl wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pages related to [[Installing Moodle|installing]] and [[Upgrading|upgrading]] Moodle.&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Catégorie:Installation]]&lt;br /&gt;
[[pl:Kategoria:Instalacja]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Administrator_documentation&amp;diff=30912</id>
		<title>Administrator documentation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Administrator_documentation&amp;diff=30912"/>
		<updated>2008-01-06T11:05:26Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The purpose of this page is to list useful links by general topics for administrators.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Upgrading ==&lt;br /&gt;
&lt;br /&gt;
*[[Installation Quickstart]] for an overview of the installation steps&lt;br /&gt;
*[[Installing Moodle]] for detailed installation instructions&lt;br /&gt;
*[[Installation FAQ]]&lt;br /&gt;
*[[Installing AMP|Installing Apache, MySQL and PHP]]&lt;br /&gt;
*[[Upgrading|Upgrading Moodle]]&lt;br /&gt;
&lt;br /&gt;
== System-specific Instructions &amp;amp; Packages ==&lt;br /&gt;
&lt;br /&gt;
* [[SUSE Linux Server 10|Automated Installation Guide for SUSE Linux Enterprise Server 10]] operating system&lt;br /&gt;
* [[RedHat Linux installation|Step by Step Installation Guide for RedHat]] operating system&lt;br /&gt;
* [[Debian GNU/Linux installation|Step by Step Installation Guide for Debian GNU/Linux]] operating system&lt;br /&gt;
* [[Step-by-step Install Guide for Ubuntu]]&lt;br /&gt;
* [[Windows installation|Complete Install Packages for Windows XP and instructions for Windows NT/2000/2003 servers]]&lt;br /&gt;
* [[Complete Install Packages for Mac OS X | Complete Install Packages for Mac OS X 10.3/10.4/10.5]]&lt;br /&gt;
* [[Step-by-step Guide for Installing Moodle on Mac OS X 10.4 Client | Step-by-Step Guide for Installing Moodle using the internal web server on Mac OS X 10.4 Client]]&lt;br /&gt;
* [[1and1_MySQL_installation | Installation on 1and1 web hosting]]&lt;br /&gt;
* [[OLPC XS installation|Step by Step Installation Guide for the One Laptop per Child XS Server (Beta)]]&lt;br /&gt;
&lt;br /&gt;
==Security, Performance and Roles==&lt;br /&gt;
&lt;br /&gt;
*[[Security]] contains important security procedures for a production site&lt;br /&gt;
*[[Performance | Performance and optimization]] for ideas on improving the speed of your installation&lt;br /&gt;
*[[Manage roles | Managing roles]] For Moodle 1.7 and later&lt;br /&gt;
&lt;br /&gt;
== FAQs ==&lt;br /&gt;
&lt;br /&gt;
*[[Installation FAQ]]&lt;br /&gt;
*[[Administration FAQ]]&lt;br /&gt;
*[[Backup FAQ]]&lt;br /&gt;
&lt;br /&gt;
== Configuration Settings ==&lt;br /&gt;
*[[Site administration block]] contains configuration setting links&lt;br /&gt;
*[[Notification page]] used to update versions&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Site settings]]&lt;br /&gt;
*[[Themes]]&lt;br /&gt;
*[[Language]]&lt;br /&gt;
*[[Activity modules administration]]&lt;br /&gt;
*[[Blocks administration]]&lt;br /&gt;
*[[Filters]]&lt;br /&gt;
*[[Backup settings]]&lt;br /&gt;
*[[Editor settings]]&lt;br /&gt;
*[[Calendar settings]]&lt;br /&gt;
*[[Maintenance mode]]&lt;br /&gt;
&lt;br /&gt;
* See also: [[Location of admin settings in 1.7|Comparison between configuration settings in Moodle 1.6 &amp;amp; 1.7]]&lt;br /&gt;
&lt;br /&gt;
==User Management==&lt;br /&gt;
&lt;br /&gt;
*[[Authentication]]&lt;br /&gt;
*[[Edit user accounts]] &lt;br /&gt;
*[[Add new user|Add a new user]] - on a site&lt;br /&gt;
*[[Flat file|Upload users]] - from a file to a site&lt;br /&gt;
*[[Enrolment plugins]]&lt;br /&gt;
*[[Roles and capabilities|Assigning user a role]] - typical assignments include:&lt;br /&gt;
**[[Students|Enrol students in a course]]&lt;br /&gt;
**[[Courses (administrator)|Assign teachers]] - to a course&lt;br /&gt;
**[[Assign creators|Assign course creators]] - in a site&lt;br /&gt;
**[[Assign administrators]] - in a site&lt;br /&gt;
&lt;br /&gt;
==Other==&lt;br /&gt;
&lt;br /&gt;
*[[Courses (administrator)|Courses]] and [[Course formats|course formats]]&lt;br /&gt;
*[[Reports (administrator)]] and [[Logs]]&lt;br /&gt;
*[[Site files]]&lt;br /&gt;
*[[Moodle database|Database]]&lt;br /&gt;
*[[Environment]]&lt;br /&gt;
*[[Moodle Network]] and Moodle Community Hub&lt;br /&gt;
*[[Streaming Media]]&lt;br /&gt;
*[[Case studies (administrator)]]&lt;br /&gt;
*[[Anti-virus]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[:Category:Administrator | Index of all Administrator-related pages]]&lt;br /&gt;
*[[Integrations]]&lt;br /&gt;
*[[CVS for Administrators]]&lt;br /&gt;
*[[Email processing]]&lt;br /&gt;
*[[Search engine optimization]]&lt;br /&gt;
*[[Messaging]]&lt;br /&gt;
*[[Migration]]&lt;br /&gt;
*[[Metacourses]]&lt;br /&gt;
*[[Block layout]]&lt;br /&gt;
*[[Customizing Moodle]]&lt;br /&gt;
*[[Administrator do&#039;s and don&#039;ts]]&lt;br /&gt;
*[http://download.moodle.org/docs/using_moodle/ch16_server_admin.pdf Using Moodle Chapter 16: Moodle Administration]&lt;br /&gt;
&lt;br /&gt;
[[Category: Administrator]]&lt;br /&gt;
[[cs:Rukověť správce]]&lt;br /&gt;
[[es:Documentación para Administradores]]&lt;br /&gt;
[[eu:Kudeatzaileentzako dokumentazioa]]&lt;br /&gt;
[[fr:Documentation administrateur]]&lt;br /&gt;
[[ja:管理者ドキュメント]]&lt;br /&gt;
[[ko:관리자 문서]]&lt;br /&gt;
[[nl:Documentatie voor beheerders]]&lt;br /&gt;
[[pt:Documentação para administradores]]&lt;br /&gt;
[[ru:Администраторам]]&lt;br /&gt;
[[zh:管理员文档]]&lt;br /&gt;
[[pl:Administrator documentation]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Development:Output_functions&amp;diff=30911</id>
		<title>Development:Output functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Development:Output_functions&amp;diff=30911"/>
		<updated>2008-01-05T21:38:58Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to polish wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page tries to explain a bit how dynamic data should be sent from Moodle to the browser in an organised and standard way. Obviously it&#039;s possible to have your own output methods but, thinking that you are going to share your code (yep, this is an OpenSource project!) and in the collaborative way we try to build and maintain the system every day, it would be really better to follow the basic guidelines explained below.&lt;br /&gt;
&lt;br /&gt;
By using them you will be helping to have better, more secure and readable code. Spend some minutes trying to understand them, please!&lt;br /&gt;
&lt;br /&gt;
Of course, these functions can be discussed, modified and new functions can arrive if there are some good reasons for it. Just discuss it in the [http://moodle.org/mod/forum/view.php?id=55 General developer forum] at [http://moodle.org moodle.org].&lt;br /&gt;
&lt;br /&gt;
For each of the functions below we&#039;ll try to explain when they should be used, explaining the most important parameters supported and their meaning. Let&#039;s review them!&lt;br /&gt;
&lt;br /&gt;
=== p() and s() ===&lt;br /&gt;
&lt;br /&gt;
 function s($var, $strip=false)&lt;br /&gt;
 function p($var, $strip=false)&lt;br /&gt;
&lt;br /&gt;
These functions share the same code so they will be explained together. The only difference is that s() returns the string while p() prints it directly.&lt;br /&gt;
&lt;br /&gt;
These functions should be used to:&lt;br /&gt;
&lt;br /&gt;
* print all the &#039;&#039;&#039;values of form fields&#039;&#039;&#039; like &amp;lt;nowiki&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/nowiki&amp;gt; or &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; tags.&lt;br /&gt;
* to &#039;&#039;&#039;show plain (non html) text&#039;&#039;&#039; that has been introduced by the user (search string, quiz responses...).&lt;br /&gt;
* in general, all the &#039;&#039;&#039;dynamic data, not being html&#039;&#039;&#039;, that doesn&#039;t need to be cleaned nor processed by filters&lt;br /&gt;
&lt;br /&gt;
It is important not to use these functions for strings that contain html markup.&lt;br /&gt;
&lt;br /&gt;
The functions replace certain characters that would have special meaning in html ( &amp;lt;, &amp;gt;, &amp;quot;, &#039;, and &amp;amp;) by html entities so that they are displayed as intended. Note that even though the value of form fields printed with p() will have these characters converted to html entities, the submitted values will contain the original characters again.&lt;br /&gt;
&lt;br /&gt;
The key parameter for this function is:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;strip&#039;&#039;&#039;: it decides if we want to strip slashes from the string or no. By default it&#039;s &#039;false&#039; so no strip will be performed. We should set such parameter to &#039;true&#039; only when data to be processed isn&#039;t coming from database but from http requests (forms, links...).&lt;br /&gt;
&lt;br /&gt;
=== format_text() ===&lt;br /&gt;
&lt;br /&gt;
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) &lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;any html/plain/markdown/moodle text&#039;&#039;&#039;, needing any of the features below. Mainly used for long strings like posts, answers, glossary items...&lt;br /&gt;
&lt;br /&gt;
Note that this function is really &#039;&#039;&#039;heavy&#039;&#039;&#039; because it supports &#039;&#039;&#039;cleaning&#039;&#039;&#039; of dangerous contents, delegates processing to enabled &#039;&#039;&#039;filter&#039;&#039;&#039;s, supports different &#039;&#039;&#039;formats&#039;&#039;&#039; of text (HTML, PLAIN, MARKDOWN, MOODLE) and performs a lot of &#039;&#039;&#039;automatic conversions&#039;&#039;&#039; like adding smilies, build links. Also, it includes a strong &#039;&#039;&#039;cache mechanism&#039;&#039;&#039; (DB based) that will alleviate the server from a lot of work processing the same texts time and again.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;format&#039;&#039;&#039;: To tell the function about how the data has been entered. It defaults to FORMAT_MOODLE that is a cool format to process plain text because it features automatic link conversion, smilies and good conversion to html output. Other formats are FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN. See [[Formatting options]].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;options&#039;&#039;&#039;: Here we can specify how we want the process to be performed. You only need to define them if they are different from the default value assumed. Main options are:&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;noclean&#039;&#039;&#039;: To decide if we want to skip the clean of text, &#039;&#039;&#039;un-protecting us&#039;&#039;&#039; from attacks and other security flaws (defaults to false, so protection is enabled. You &#039;&#039;&#039;shouldn&#039;t set it to true ever&#039;&#039;&#039; unless you are 200% sure that only controlled users can edit it (mainly admins). &#039;&#039;&#039;Never use it for general text places&#039;&#039;&#039; (posts...) or you will be, sooner or later, attacked! Note that this option is ignored for FORMAT_PLAIN, the text is never cleaned.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;filter&#039;&#039;&#039;: To decide if you want to allow filters to process the text (defaults to true). This is ignored by FORMAT_PLAIN for which filters are never applied.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;smiley&#039;&#039;&#039;: To decide if we want automatic conversion of smilies to images (defaults to true). This is ignored by FORMAT_PLAIN for which smileys are never converted.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;para&#039;&#039;&#039;: To decide if you want every paragraph automatically enclosed between html paragraph tags (&amp;lt;nowiki&amp;gt;&amp;lt;p&amp;gt;...&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;newlines&#039;&#039;&#039;: To decide if linefeeds in text should be converted to html newlines (&amp;lt;nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== format_string() ===&lt;br /&gt;
&lt;br /&gt;
 function format_string ($string, $striplinks = true, $courseid=NULL )&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;short strings (non html) that need filter processing&#039;&#039;&#039; (activity titles, post subjects, glossary concepts...).&lt;br /&gt;
&lt;br /&gt;
Please note that this function is basically one stripped version of the full format_text() function detailed above and &#039;&#039;&#039;it doesn&#039;t offer any of its options or protections&#039;&#039;&#039;. It simply filters the strings and returns the result, so we must ensure that text being processed has been properly cleaned at input time, using the proper xxx_param() functions.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;striplinks&#039;&#039;&#039;: To decide if, after the text has been processed by filters, we must delete any link from the result text. Used when we want to show the text inside menus, page titles... (defaults to true).&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== print_textarea() ===&lt;br /&gt;
&lt;br /&gt;
 function print_textarea($usehtmleditor, $rows, $cols, $width, &lt;br /&gt;
                        $height, $name, $value=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, $courseid=0, $return=false)&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* display &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; fields when we want to allow users (based in their preferences and browser capabilities) &#039;&#039;&#039;to use the visual HTML editor&#039;&#039;&#039; instead of one standard &#039;plain&#039; area.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;usehtmleditor&#039;&#039;&#039;: to decide if the HTML editor must be showed. The value of this parameter must be calculated by the can_use_html_editor() function.&lt;br /&gt;
* &#039;&#039;&#039;rows, cols&#039;&#039;&#039;: to be applied it the standard textarea is showed.&lt;br /&gt;
* &#039;&#039;&#039;width, height&#039;&#039;&#039;: to be applied if the HTML editor is used.&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039;: the name of the field that will contain the text once the form is submitted.&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039;: the initial value of the textarea.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help the editor to know where it is work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
* &#039;&#039;&#039;return&#039;&#039;&#039;: to decide if the generated html code must be returned to the caller (true) or printed directly (false). Defaults to false.&lt;br /&gt;
&lt;br /&gt;
[[pl:Funkcje wyjściowe]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Output functions]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Development:Coding&amp;diff=30884</id>
		<title>Development:Coding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Development:Coding&amp;diff=30884"/>
		<updated>2008-01-05T14:35:59Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Any collaborative project needs consistency and stability to stay strong.&lt;br /&gt;
&lt;br /&gt;
These &#039;&#039;&#039;coding guidelines&#039;&#039;&#039; are to provide a goal for all Moodle code to strive to. It&#039;s true that some of the older existing code falls short in a few areas, but it will all be fixed eventually. All new code definitely must adhere to these standards as closely as possible.&lt;br /&gt;
&lt;br /&gt;
==General rules==&lt;br /&gt;
&lt;br /&gt;
# All code files should use the .php extension.&lt;br /&gt;
# All template files should use the .html extension.&lt;br /&gt;
# All text files should use Unix-style text format (most text editors have this as an option).&lt;br /&gt;
# All php tags must be &#039;full&#039; tags like &amp;lt;?php ?&amp;gt; ... not &#039;short&#039; tags like &amp;lt;? ?&amp;gt;.&lt;br /&gt;
# All existing copyright notices must be retained. You can add your own if necessary.&lt;br /&gt;
# Each file should include (require_once) the main config.php file.&lt;br /&gt;
# Any other include/require should use an absolute path beginning with $CFG-&amp;gt;dirroot or  $CFG-&amp;gt;libdir, not relative includes, which [http://uk.php.net/manual/en/function.include.php sometimes behave strangely under PHP].&lt;br /&gt;
# Each file should check that the user is authenticated correctly, using require_login() and has_capability() or require_capability().&lt;br /&gt;
# All access to databases should use the functions in &#039;&#039;lib/dmllib.php&#039;&#039; whenever possible - this allows compatibility across a wide range of databases. You should find that almost anything is possible using these functions. If you must write SQL code then make sure it is: cross-platform; restricted to specific functions within your code (usually a lib.php file); and clearly marked.&lt;br /&gt;
# Don&#039;t create or use global variables except for the standard $CFG, $SESSION, $THEME, $SITE, $COURSE and $USER.&lt;br /&gt;
# All variables should be initialised or at least tested for existence using isset() or empty() before they are used.&lt;br /&gt;
# All strings should be translatable - create new texts in the &amp;quot;lang/en_utf8&amp;quot; files with concise English lowercase names and retrieve them from your code using get_string() or print_string(). Never delete strings to ensure backwards compatibility of the language packs is maintained.&lt;br /&gt;
# All errors should be printed using print_error() to maximise translation and help for users (it automatically links to the docs wiki).&lt;br /&gt;
# All help files should be translatable - create new texts in the &amp;quot;lang/en_utf8/help&amp;quot; directory and call them using helpbutton(). If you need to update a help file:&lt;br /&gt;
#* with a minor change, where an old translation of the file would still make sense, then it&#039;s OK to make the change but you should notify translation AT moodle DOT org.&lt;br /&gt;
#* for a major change you should create a new file by adding an incrementing number (eg filename2.html) so that translators can easily see it&#039;s a new version of the file. Obviously the new code and the help index files should also be modified to point to the newest versions.&lt;br /&gt;
# Incoming data from the browser (sent via GET or POST) automatically has magic_quotes applied (regardless of the PHP settings) so that you can safely insert it straight into the database. All other raw data (from files, or from databases) must be escaped with addslashes() before inserting it into the database. Because this is so often done incorrectly, there is more explanation on this issue of adding and stripping slashes on a [[Developer:Slashes|separate page]].&lt;br /&gt;
# VERY IMPORTANT: All texts within Moodle, especially those that have come from users, should be printed using the format_text() function. This ensures that text is filtered and cleaned correctly. More information can be found on the page about [[Development:Output_functions|output functions]].&lt;br /&gt;
# User actions should be logged using the [[Development:Logs|add_to_log()]] function. These logs are used for [[Settings#Show_activity_reports|activity reports]] and [[Logs]].&lt;br /&gt;
# When generating a HTML link, always make it relative to the full site root, i.e. link to  &#039;&#039;$CFG-&amp;gt;wwwroot/mod/blonk/view.php?id=99&#039;&#039; rather than just &#039;&#039;view.php?id=99&#039;&#039;. This means that your code will work if called by a script in another folder, among other things.&lt;br /&gt;
&lt;br /&gt;
==Coding style==&lt;br /&gt;
&lt;br /&gt;
I know it can be a little annoying to change your style if you&#039;re used to something else, but balance that annoyance against the annoyance of all the people trying later on to make sense of Moodle code with mixed styles. There are obviously many good points for and against any style that people use, but the current style just is, so please stick to it.&lt;br /&gt;
&lt;br /&gt;
1. Indenting should be consistently 4 spaces. Don&#039;t use tabs AT ALL.&lt;br /&gt;
&lt;br /&gt;
2. Variable names should always be easy-to-read, meaningful lowercase English words. If you really need more than one word then run them together, but keep them short as possible. Use plural names for arrays of objects.&lt;br /&gt;
&lt;br /&gt;
      GOOD: $quiz&lt;br /&gt;
      GOOD: $errorstring&lt;br /&gt;
      GOOD: $assignments (for an array of objects)&lt;br /&gt;
      GOOD: $i (but only in little loops)&lt;br /&gt;
&lt;br /&gt;
      BAD: $Quiz&lt;br /&gt;
      BAD: $aReallyLongVariableNameWithoutAGoodReason&lt;br /&gt;
      BAD: $error_string&lt;br /&gt;
&lt;br /&gt;
3. Constants should always be in upper case, and always start with the name of the module. They should have words separated by underscores.&lt;br /&gt;
&lt;br /&gt;
      define(&amp;quot;FORUM_MODE_FLATOLDEST&amp;quot;, 1);&lt;br /&gt;
4. Function names should be simple English lowercase words, and start with the name of the module to avoid conflicts between modules. Words should be separated by underscores. Parameters should always have sensible defaults if possible. Note there is no space between the function name and the following (brackets).&lt;br /&gt;
&lt;br /&gt;
      function forum_set_display_mode($mode=0) {&lt;br /&gt;
          global $USER, $CFG;&lt;br /&gt;
          &lt;br /&gt;
          if ($mode) {&lt;br /&gt;
              $USER-&amp;gt;mode = $mode;&lt;br /&gt;
          } else if (empty($USER-&amp;gt;mode)) {&lt;br /&gt;
              $USER-&amp;gt;mode = $CFG-&amp;gt;forum_displaymode;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
5. Blocks must always be enclosed in curly braces (even if there is only one line). Moodle uses this style:&lt;br /&gt;
&lt;br /&gt;
      if ($quiz-&amp;gt;attempts) {&lt;br /&gt;
          if ($numattempts &amp;gt; $quiz-&amp;gt;attempts) {&lt;br /&gt;
              error($strtoomanyattempts, &amp;quot;view.php?id=$cm-&amp;gt;id&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
6. Strings should be defined using single quotes where possible, so that [http://php.net/types.string less memory is used].&lt;br /&gt;
&lt;br /&gt;
      $var = &#039;some text without any variables&#039;;&lt;br /&gt;
      $var = &#039;with special characters like a new line &#039;.&amp;quot;\n&amp;quot;;&lt;br /&gt;
      $var = &#039;a very, very long string with a &#039;.$single.&#039; variable in it&#039;;&lt;br /&gt;
      $var = &#039;some &#039;.$text.&#039; with &#039;.$many.&#039; variables &#039;.$within.&#039; it&#039;;&lt;br /&gt;
&lt;br /&gt;
7. Comments should be added as much as is practical, to explain the code flow and the purpose of functions and variables.&lt;br /&gt;
&lt;br /&gt;
* Every function (and class) should use the popular [http://www.phpdoc.org/ phpDoc format]. This allows code documentation to be generated automatically.&lt;br /&gt;
* Inline comments should use the // style, laid out neatly so that it fits among the code and lines up with it.&lt;br /&gt;
&lt;br /&gt;
      /**&lt;br /&gt;
      * The description should be first, with asterisks laid out exactly&lt;br /&gt;
      * like this example. If you want to refer to a another function,&lt;br /&gt;
      * do it like this: {@link clean_param()}. Then, add descriptions&lt;br /&gt;
      * for each parameter as follows.&lt;br /&gt;
      *&lt;br /&gt;
      * @param int $postid The PHP type is followed by the variable name&lt;br /&gt;
      * @param array $scale The PHP type is followed by the variable name&lt;br /&gt;
      * @param array $ratings The PHP type is followed by the variable name&lt;br /&gt;
      * @return mixed&lt;br /&gt;
      */&lt;br /&gt;
      function forum_get_ratings_mean($postid, $scale, $ratings=NULL) {&lt;br /&gt;
          if (!$ratings) {&lt;br /&gt;
              $ratings = array();     // Initialize the empty array&lt;br /&gt;
              if ($rates = get_records(&amp;quot;forum_ratings&amp;quot;, &amp;quot;post&amp;quot;, $postid)) {&lt;br /&gt;
                  // Process each rating in turn&lt;br /&gt;
                  foreach ($rates as $rate) {&lt;br /&gt;
      ....etc&lt;br /&gt;
&lt;br /&gt;
8. Space should be used liberally - don&#039;t be afraid to spread things out a little to gain some clarity. Generally, there should be one space between brackets and normal statements, but no space between brackets and variables or functions:&lt;br /&gt;
&lt;br /&gt;
      foreach ($objects as $key =&amp;gt; $thing) {&lt;br /&gt;
          process($thing);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      if ($x == $y) {&lt;br /&gt;
          $a = $b;&lt;br /&gt;
      } else if ($x == $z) {&lt;br /&gt;
          $a = $c;&lt;br /&gt;
      } else {&lt;br /&gt;
          $a = $d;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
9. When making a COPY of an object, always use the php5 clone() function (otherwise you may end up with just a reference to the first object).  Moodle will make sure this works consistently on php4 too.&lt;br /&gt;
&lt;br /&gt;
      BAD:   $b = $a;&lt;br /&gt;
      GOOD:  $b = clone($a);&lt;br /&gt;
&lt;br /&gt;
If the thing you want to copy is not an object, but may contain objects (eg an array of objects) then use fullclone() instead.&lt;br /&gt;
&lt;br /&gt;
==Database structures==&lt;br /&gt;
&lt;br /&gt;
To help you create tables that meet these guidelines, we recommend you use the built in [[Development:XMLDB_defining_an_XML_structure#The_XMLDB_editor|database definition (XMLDB) editor]].&lt;br /&gt;
&lt;br /&gt;
# Every table must have an auto-incrementing id field (INT10) as primary index. (see [[IdColumnReasons]])&lt;br /&gt;
# The main table containing instances of each module must have the same name as the module (eg widget) and contain the following minimum fields:&lt;br /&gt;
#* id - as described above&lt;br /&gt;
#* course - the id of the course that each instance belongs to&lt;br /&gt;
#* name - the full name of each instance of the module&lt;br /&gt;
# Other tables associated with a module that contain information about &#039;things&#039; should be named widget_things (note the plural).&lt;br /&gt;
# Table and column names should avoid using [[Database reserved words|reserved words in any database]]. Please check them before creation.&lt;br /&gt;
# Column names should be always lowercase, simple and short, following the same rules as for variable names.&lt;br /&gt;
# Where possible, columns that contain a reference to the id field of another table (eg widget) should be called widgetid. (Note that this convention is newish and not followed in some older tables)&lt;br /&gt;
# Boolean fields should be implemented as small integer fields (eg INT4) containing 0 or 1, to allow for later expansion of values if necessary.&lt;br /&gt;
# Most tables should have a timemodified field (INT10) which is updated with a current timestamp obtained with the PHP time() function.&lt;br /&gt;
# Always define a default value for each field (and make it sensible)&lt;br /&gt;
# Each table name should start with the database prefix ($CFG-&amp;gt;prefix). In a lot of cases, this is taken care of for you automatically. Also, under Postgres, the name of every index must start with the prefix too.&lt;br /&gt;
# In order to guarantee [[Development:XMLDB problems#Table and column aliases - the AS keyword|cross-db compatibility]] follow these simple rules about the use of the &#039;&#039;&#039;AS&#039;&#039;&#039; keyword (only if you need table/colum aliases, of course):&lt;br /&gt;
#* &#039;&#039;&#039;Don&#039;t use&#039;&#039;&#039; the &#039;&#039;&#039;AS&#039;&#039;&#039; keyword for &#039;&#039;&#039;table aliases&#039;&#039;&#039;.&lt;br /&gt;
#* &#039;&#039;&#039;Do use&#039;&#039;&#039; the &#039;&#039;&#039;AS&#039;&#039;&#039; keyword for &#039;&#039;&#039;column aliases&#039;&#039;&#039;.&lt;br /&gt;
# &#039;&#039;&#039;Never&#039;&#039;&#039; create UNIQUE KEYs (constraints) at all. Instead use UNIQUE INDEXes. In the future, if we decide to add referential integrity to Moodle and we need UNIQUE KEYs they will be used, but not now. Please note that the XMLDB editor allows you to specify both XMLDB-only UNIQUE and FOREIGN constraints (and that&#039;s good, in order to have the XML well defined) but only underlying INDEXes will be generated. &lt;br /&gt;
# Those XMLDB-only UNIQUE KEYs (read previous point) only must be defined if such field/fields &#039;&#039;&#039;are going to be the target&#039;&#039;&#039; for some (XMLDB-only too) FOREIGN KEY. Else, create them as simple UNIQUE INDEXes.&lt;br /&gt;
# Tables associated &#039;&#039;&#039;with one block&#039;&#039;&#039; must follow this convention with their names: &#039;&#039;&#039;$CFG-&amp;gt;prefix + &amp;quot;block_&amp;quot; + name_of_the_block + anything_else&#039;&#039;&#039;. For example, assuming that $CFG-&amp;gt;prefix is &#039;mdl_&#039;, all the tables for the block &amp;quot;rss_client&amp;quot; must start by &#039;mdl_block_rss_client&#039; (being possible to add more words at the end, i.e. &#039;mdl_block_rss_client_anothertable&#039;...). This rule will be 100% enforced with Moodle 2.0, giving time to developers until then. See [http://tracker.moodle.org/browse/MDL-6786 Task 6786] for more info about this.&lt;br /&gt;
# &#039;&#039;&#039;Never&#039;&#039;&#039; make database changes in the STABLE branches.  If we did, then users upgrading from one stable version to the next would have duplicate changes occurring, which may cause serious errors.&lt;br /&gt;
# When refering to integer variable in SQL queries, do not surround the value in quotes. For example, get_records_select(&#039;question&#039;, &amp;quot;category=$catid&amp;quot;) is right. get_records_select(&#039;question&#039;, &amp;quot;category=&#039;$catid&#039;&amp;quot;) is wrong. It hides bugs where $catid is undefined. ([http://moodle.org/mod/forum/discuss.php?d=80629 This thread explains].)&lt;br /&gt;
&lt;br /&gt;
==Security issues (and handling form and URL data)==&lt;br /&gt;
&lt;br /&gt;
# Do not rely on &#039;register_globals&#039;. Every variable must be properly initialised in every code file. It must be obvious where the variable came from.&lt;br /&gt;
# Initialise all arrays and objects, even if empty. $a = array() or $obj = new stdClass();.&lt;br /&gt;
# Do not use the optional_variable() function (this function is now deprecated). Use the optional_param() function instead. Pick the correct PARAM_XXXX value for the data type you expect.&lt;br /&gt;
# Do not use the require_variable() function (this function is now deprecated). Use the required_param() function instead. Pick the correct PARAM_XXXX value for the data type you expect.&lt;br /&gt;
# Use data_submitted(), with care. Data must still be cleaned before use.&lt;br /&gt;
# Do not use $_GET, $_POST or $_REQUEST. Use the appropriate required_param() or optional_param() appropriate to your need.&lt;br /&gt;
# Do not check for an action using something like if (isset($_GET[&#039;something&#039;])). Use, e.g., $something = optional_param( &#039;something&#039;,-1,PARAM_INT ) and then perform proper test for it being in its expected range of values e.g., if ($something&amp;gt;=0) {....&lt;br /&gt;
# Wherever possible group all your required_param(), optional_param() and other variables initialisation at the beginning of each file to make them easy to find.&lt;br /&gt;
# Use &#039;sesskey&#039; mechanism to protect form handling routines from attack. Basic example of use: when form is generated, include &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;sesskey&amp;quot; value=&amp;quot;&amp;lt;?php echo sesskey(); ?&amp;gt;&amp;quot; /&amp;gt;. When you process the form check with if (!confirm_sesskey()) {error(&#039;Bad Session Key&#039;);}.&lt;br /&gt;
# All filenames must be &#039;cleaned&#039; using the clean_filename() function, if this has not been done already by appropriate use of required_param() or optional_param()&lt;br /&gt;
# Any data read from the database must have [[Developer:Slashes|addslashes()]] applied to it before it can be written back. A whole object of data can be hit at once with addslashes_object().&lt;br /&gt;
# Wherever possible, data to be stored in the database must come from POST data (from a form with method=&amp;quot;POST&amp;quot;) as opposed to GET data (ie, data from the URL line).&lt;br /&gt;
# Do not use data from $_SERVER if you can avoid it. This has portability issues.&lt;br /&gt;
# If it hasn&#039;t been done somewhere else, make sure all data written to the database has been through the clean_param() function using the appropriate PARAM_XXXX for the datatype.&lt;br /&gt;
# If you write custom SQL code, make very sure it is correct. In particular watch out for missing quotes around values. Possible SQL &#039;injection&#039; exploit.&lt;br /&gt;
# Check all data (particularly that written to the database) in every file it is used. Do not expect or rely on it being done somewhere else.&lt;br /&gt;
# Blocks of code to be included should contain a definite PHP structure (e.g, a class declaration, function definition(s) etc.) - straight blocks of code promote uninitialised variable usage.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Coding]]&lt;br /&gt;
&lt;br /&gt;
[[es:Manual de Estilo de Código]]&lt;br /&gt;
[[ja:コーディング]]&lt;br /&gt;
[[zh:代码指南]]&lt;br /&gt;
[[pl:Kodowanie]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Development:Developer_FAQ&amp;diff=30883</id>
		<title>Development:Developer FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Development:Developer_FAQ&amp;diff=30883"/>
		<updated>2008-01-05T14:32:51Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{FAQ}}&lt;br /&gt;
&lt;br /&gt;
==Help for new coders==&lt;br /&gt;
&lt;br /&gt;
===Where can &amp;quot;newbies&amp;quot; to Moodle get help?===&lt;br /&gt;
&lt;br /&gt;
The [http://moodle.org/mod/forum/view.php?f=33 General developer forum]! Feel free to ask any question, no matter how basic or advanced. Many people ask different levels of question every day, and the community is generally welcoming and quick to respond.&lt;br /&gt;
&lt;br /&gt;
==Moodle&#039;s database==&lt;br /&gt;
&lt;br /&gt;
===Where can I see a schema for the structure of the Moodle database?===&lt;br /&gt;
&lt;br /&gt;
When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the [[Coding#Database_structures | coding guidelines for database structure]] give an outline of the general approach.&lt;br /&gt;
&lt;br /&gt;
The reason that the database information isn&#039;t stored in one place is because of Moodle&#039;s &#039;&#039;&#039;modular structure&#039;&#039;&#039;. Each activity module, for example, comes as a folder with script files inside. If the module needs to store information in the database, it must include scripts in a &amp;quot;db&amp;quot; subfolder which define and update the database structure.&lt;br /&gt;
&lt;br /&gt;
==How to get/set information when writing new Moodle code==&lt;br /&gt;
&lt;br /&gt;
===How do I find out the currently-logged-on user?===&lt;br /&gt;
&lt;br /&gt;
The global object $USER, which contains the numeric $USER-&amp;gt;id among other things.&lt;br /&gt;
&lt;br /&gt;
===How do I find out the current course?===&lt;br /&gt;
The global object $COURSE, which contains the numeric $COURSE-&amp;gt;id&lt;br /&gt;
&lt;br /&gt;
===How do I insert/retrieve records in the database, without creating my own database connections?===&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;datalib&amp;quot; functions, such as insert_record() or get_record(). Since Moodle 1.7 these are found in lib/dmllib.php. Using these functions helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.&lt;br /&gt;
&lt;br /&gt;
Look at [http://phpdocs.moodle.org/moodlecore/_lib---datalib.php.html  the documentation for datalib.php] for the list of functions and details of use.&lt;br /&gt;
&lt;br /&gt;
===How do I get/set configuration settings?===&lt;br /&gt;
&lt;br /&gt;
To get config values you would typically access the global $CFG object directly, which is automatically created by the core Moodle scripts. To set these &amp;quot;main&amp;quot; config values use set_config($name, $value). The values are stored in the Moodle &amp;quot;config&amp;quot; database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.&lt;br /&gt;
&lt;br /&gt;
There is also a second table of config settings specifically for plugins (&amp;quot;config_plugin&amp;quot;). These are not automatically loaded into the $CFG object, so to fetch these you would use get_config($plugin, $name). To set them use set_config($name, $value, $plugin).&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=55719 How does date / time in DB convert to real Date / Time?] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category: Developer]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[es:FAQ Desarrollador]]&lt;br /&gt;
[[fr:FAQ de développement]]&lt;br /&gt;
[[pl:Developer FAQ]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=Category:FAQ&amp;diff=30882</id>
		<title>Category:FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=Category:FAQ&amp;diff=30882"/>
		<updated>2008-01-05T14:32:02Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An FAQ is a list of Frequently Asked Questions, along with their answers.&lt;br /&gt;
&lt;br /&gt;
==Other sources of help==&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t find the answer to your question in one of FAQ pages listed below, please try&lt;br /&gt;
&lt;br /&gt;
* [[MoodleDocs:Searching|Searching Moodle Docs]]&lt;br /&gt;
* Browsing the moodle.org [http://moodle.org/course/view.php?id=5 Using Moodle course]&lt;br /&gt;
&lt;br /&gt;
[[Category:Teacher]]&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Catégorie:FAQ]]&lt;br /&gt;
[[pl:Kategoria:FAQ]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=PHP_info&amp;diff=30880</id>
		<title>PHP info</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=PHP_info&amp;diff=30880"/>
		<updated>2008-01-05T13:38:37Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Location: &#039;&#039;Administration &amp;gt; Server &amp;gt; PHP info&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The phpinfo display contains information about the configuration of your PHP installation. This is useful for checking:&lt;br /&gt;
* that your PHP installation meets Moodle&#039;s system requirements.&lt;br /&gt;
* that you have installed the required modules needed for Moodle to work, e.g. the LDAP module for LDAP authentication.&lt;br /&gt;
&lt;br /&gt;
==Displaying phpinfo==&lt;br /&gt;
To view the phpinfo information:&lt;br /&gt;
* In Moodle version 1.7 or greater, choose Site Administration -&amp;gt; Server -&amp;gt; PHP info.&lt;br /&gt;
* Create a file called info.php using your text editor, containing this single line:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php phpinfo(); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sample output==&lt;br /&gt;
This is a sample output displayed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; width=&amp;quot;600&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr class=&amp;quot;h&amp;quot;&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
[http://www.php.net/ http://www.php.net]&lt;br /&gt;
=PHP Version 4.3.3=&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; width=&amp;quot;600&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;System &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Windows NT MYLAPTOP0106 5.1 build 2600 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Build Date &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Aug 24 2003 22:01:16 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Server API &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Apache &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Virtual Directory Support &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;enabled &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Configuration File (php.ini) Path &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;C:\WINDOWS\php.ini &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;PHP API &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20020918 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;PHP Extension &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20020429 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Zend Extension &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20021010 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Debug Build &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Thread Safety &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;enabled &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Registered PHP Streams &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;php, http, ftp, compress.zlib&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
This output goes on for about 5 pages.&lt;br /&gt;
&lt;br /&gt;
[[es:phpinfo]]&lt;br /&gt;
[[pt:phpinfo]]&lt;br /&gt;
[[pl:phpinfo]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Phpinfo]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/35/en/index.php?title=PHP_info&amp;diff=30879</id>
		<title>PHP info</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/35/en/index.php?title=PHP_info&amp;diff=30879"/>
		<updated>2008-01-05T13:37:15Z</updated>

		<summary type="html">&lt;p&gt;Szymonk: added inter-language link to polish wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Location: &#039;&#039;Administration &amp;gt; Server &amp;gt; PHP info&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The phpinfo display contains information about the configuration of your PHP installation. This is useful for checking:&lt;br /&gt;
* that your PHP installation meets Moodle&#039;s system requirements.&lt;br /&gt;
* that you have installed the required modules needed for Moodle to work, e.g. the LDAP module for LDAP authentication.&lt;br /&gt;
&lt;br /&gt;
==Displaying phpinfo==&lt;br /&gt;
To view the phpinfo information:&lt;br /&gt;
* In Moodle version 1.7 or greater, choose Site Administration -&amp;gt; Server -&amp;gt; PHP info.&lt;br /&gt;
* Create a file called info.php using your text editor, containing this single line:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php phpinfo(); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sample output==&lt;br /&gt;
This is a sample output displayed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; width=&amp;quot;600&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr class=&amp;quot;h&amp;quot;&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
[http://www.php.net/ http://www.php.net]&lt;br /&gt;
=PHP Version 4.3.3=&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; width=&amp;quot;600&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;System &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Windows NT MYLAPTOP0106 5.1 build 2600 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Build Date &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Aug 24 2003 22:01:16 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Server API &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;Apache &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Virtual Directory Support &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;enabled &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Configuration File (php.ini) Path &amp;lt;/td&amp;gt;&amp;lt;td class=&amp;quot;v&amp;quot;&amp;gt;C:\WINDOWS\php.ini &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;PHP API &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20020918 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;PHP Extension &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20020429 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Zend Extension &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20021010 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Debug Build &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Thread Safety &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;enabled &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td class=&amp;quot;e&amp;quot;&amp;gt;Registered PHP Streams &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;php, http, ftp, compress.zlib&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
This output goes on for about 5 pages.&lt;br /&gt;
&lt;br /&gt;
[[es:phpinfo]]&lt;br /&gt;
[[pl:phpinfo]]&lt;br /&gt;
[[pt:phpinfo]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Phpinfo]]&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Szymonk</name></author>
	</entry>
</feed>