<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/37/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Davidaylmer</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/37/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Davidaylmer"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/Special:Contributions/Davidaylmer"/>
	<updated>2026-05-09T03:41:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=PHP&amp;diff=113219</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=PHP&amp;diff=113219"/>
		<updated>2014-06-19T10:58:14Z</updated>

		<summary type="html">&lt;p&gt;Davidaylmer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
PHP is the scripting language in which Moodle is developed. It is integrated with your web server. The web server detects php pages (by their extension) and sends them to PHP for execution. PHP must be installed and configured properly for Moodle to work effectively (or at all). &lt;br /&gt;
&lt;br /&gt;
==PHP Settings==&lt;br /&gt;
Check these settings in your php.ini or .htaccess file (if you&#039;re using Apache). For settings which use ON/OFF as their values, you can substitute 1 for ON and 0 for OFF if you prefer. If you change php.ini, don&#039;t forget to restart the server. &lt;br /&gt;
* &#039;&#039;register_globals&#039;&#039; &#039;&#039;&#039;MUST&#039;&#039;&#039; be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)&lt;br /&gt;
* &#039;&#039;safe_mode&#039;&#039; needs to be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)&lt;br /&gt;
* &#039;&#039;memory_limit&#039;&#039; should be at least 64M (although some functions may not work if this low). 128M is recommended. Large systems may need an even higher setting.&lt;br /&gt;
* &#039;&#039;session.save_handler&#039;&#039; needs to be set to FILES.&lt;br /&gt;
* &#039;&#039;magic_quotes_gpc&#039;&#039; should be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)&lt;br /&gt;
* &#039;&#039;magic_quotes_runtime&#039;&#039; needs to be OFF.&lt;br /&gt;
* &#039;&#039;file_uploads&#039;&#039; needs to be ON.&lt;br /&gt;
* &#039;&#039;session.auto_start&#039;&#039; needs to be OFF.&lt;br /&gt;
* &#039;&#039;session.bug_compat_warn&#039;&#039; needs to be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)&lt;br /&gt;
* The temp folder must be defined and writeable by your webserver user&lt;br /&gt;
* Check the error display/logging section. Make sure the settings are appropriate for your server use.&lt;br /&gt;
* &#039;&#039;post_max_size&#039;&#039; and &#039;&#039;upload_max_filesize&#039;&#039; restrict the maximum file size that can be uploaded.&lt;br /&gt;
* Check the &#039;&#039;[mail function]&#039;&#039; and database section (for your chosen database) to make sure they match your server configuration.&lt;br /&gt;
&lt;br /&gt;
==Finding the correct php.ini==&lt;br /&gt;
Sometimes it is not obvious where the php.ini file is located or you may even find more than one. To be certain run &#039;phpinfo&#039; - see below. The path of the php.ini file is a few lines down in the top section. &lt;br /&gt;
&lt;br /&gt;
Note that if you are using command-line (CLI) PHP for running cron (or anything else) it may be configured with a &#039;&#039;different&#039;&#039; php.ini file.  To check, run the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
php -i | grep php.ini&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==PHP Extensions and libraries==&lt;br /&gt;
The following PHP extensions are required or recommended (some, e.g. iconv, ctype and tokenizer are now included in PHP by default). Others will need to be installed or selected.&lt;br /&gt;
* The &#039;&#039;&#039;iconv&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;mbstring&#039;&#039;&#039; extension is recommended.&lt;br /&gt;
* The &#039;&#039;&#039;curl&#039;&#039;&#039; extension is required (required for networking and web services).&lt;br /&gt;
* The &#039;&#039;&#039;openssl&#039;&#039;&#039; extension is recommended (required for networking and web services).&lt;br /&gt;
* The &#039;&#039;&#039;tokenizer&#039;&#039;&#039; extension is recommended.&lt;br /&gt;
* The &#039;&#039;&#039;xmlrpc&#039;&#039;&#039; extension is recommended (required for networking and web services).&lt;br /&gt;
* The &#039;&#039;&#039;soap&#039;&#039;&#039; extension is recommended (required for web services).&lt;br /&gt;
* The &#039;&#039;&#039;ctype&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;zip&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;gd&#039;&#039;&#039; extension is recommended (required for manipulating images).&lt;br /&gt;
* The &#039;&#039;&#039;simplexml&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;spl&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;pcre&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;dom&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;xml&#039;&#039;&#039; extension is required.&lt;br /&gt;
* The &#039;&#039;&#039;intl&#039;&#039;&#039; extension is recommended.&lt;br /&gt;
* The &#039;&#039;&#039;json&#039;&#039;&#039; extension is required.&lt;br /&gt;
* &#039;&#039;&#039;The appropriate extension for your chosen database is also required.&#039;&#039;&#039;&lt;br /&gt;
&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;
&lt;br /&gt;
==Installing (missing) extensions==&lt;br /&gt;
&lt;br /&gt;
This depends on how PHP was installed on your machine and what access you have. Here are some possibilities:&lt;br /&gt;
* If this is a hosted server you are likely to have to ask the administrator or hosting company. &lt;br /&gt;
* If PHP was compiled from source you will need to recompile, changing the &#039;configure&#039; settings - see [[Compiling PHP from source]].&lt;br /&gt;
* If it was installed using packages (typically Linux) you can install the required package (see your Linux distribution&#039;s documentation)&lt;br /&gt;
* If you are using Windows you just need to uncomment the appropriate DLL files in php.ini&lt;br /&gt;
&lt;br /&gt;
After making any changes or additions, don&#039;t forget to re-start your web server.&lt;br /&gt;
&lt;br /&gt;
== .htaccess files ==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have access to the php.ini file or there are conflicting requirements with other PHP applications on the same server you may be able to change PHP settings in an .htaccess file. This should be placed in the &#039;root&#039; of your Moodle installation (i.e. the same place as the config.php file). &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The file isn&#039;t always called .htaccess and may not work at all. Contact your server administrator to be sure&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Settings are made by adding lines in one of two formats:&lt;br /&gt;
* php_value &#039;&#039;name value&#039;&#039;&lt;br /&gt;
* php_flag &#039;&#039;name on/off&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* &#039;&#039;&#039;php_value memory_limit 128M&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;php_flag register_globals off&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==PHP info==&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;
* the values that are currently applied to your server&#039;s PHP install, e.g. File upload limits&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 in Moodle===&lt;br /&gt;
&lt;br /&gt;
An administrator can find PHP info in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Server &amp;gt; PHP info&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Displaying phpinfo outside of Moodle ===&lt;br /&gt;
&lt;br /&gt;
To view the phpinfo information:&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;code php&amp;gt;&lt;br /&gt;
 &amp;lt;?php phpinfo(); ?&amp;gt;&lt;br /&gt;
 &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Save this file as info.php&lt;br /&gt;
* Upload this file into the root web accessible folder on your server.&lt;br /&gt;
* Now open this file in your browser. For example &amp;lt;nowiki&amp;gt;http://&amp;lt;server-name&amp;gt;/info.php&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Compiling PHP from source]]&lt;br /&gt;
&lt;br /&gt;
*http://www.php.net/ - the PHP web site&lt;br /&gt;
*http://php.iis.net/ - Microsoft PHP Installer for IIS&lt;br /&gt;
&lt;br /&gt;
[[de:PHP-Versionen für Moodle]]&lt;br /&gt;
[[es:PHP]]&lt;/div&gt;</summary>
		<author><name>Davidaylmer</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=OPcache&amp;diff=112990</id>
		<title>OPcache</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=OPcache&amp;diff=112990"/>
		<updated>2014-06-09T01:32:44Z</updated>

		<summary type="html">&lt;p&gt;Davidaylmer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
&lt;br /&gt;
The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check message about OpCache. Nonetheless, [https://moodle.org/mod/forum/discuss.php?d=245885 it might be useful] to upgrade Operating System/PHP and get to 5.5 or newer; as there have been all sorts of problems described on PHP 5.2 and 5.3, and upgrading PHP turned out to be the easier solution. &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
PHP.ini settings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code ini&amp;gt;&lt;br /&gt;
[opcache]&lt;br /&gt;
opcache.enable = 1&lt;br /&gt;
opcache.memory_consumption = 128&lt;br /&gt;
opcache.max_accelerated_files = 4000&lt;br /&gt;
opcache.revalidate_freq = 60&lt;br /&gt;
&lt;br /&gt;
; Required for Moodle&lt;br /&gt;
opcache.use_cwd = 1&lt;br /&gt;
opcache.validate_timestamps = 1&lt;br /&gt;
opcache.save_comments = 1&lt;br /&gt;
opcache.enable_file_override = 0&lt;br /&gt;
&lt;br /&gt;
; If something does not work in Moodle&lt;br /&gt;
;opcache.revalidate_path = 1 ; May fix problems with include paths&lt;br /&gt;
;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487&lt;br /&gt;
&lt;br /&gt;
; Experimental for Moodle 2.6 and later&lt;br /&gt;
;opcache.fast_shutdown = 1&lt;br /&gt;
;opcache.enable_cli = 1 ; Speeds up CLI cron&lt;br /&gt;
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using non-Windows platforms, you have to use the &#039;&#039;zend_extension&#039;&#039; configuration to load the OPcache extension into PHP by adding to php.ini.&lt;br /&gt;
&amp;lt;code ini&amp;gt;&lt;br /&gt;
zend_extension=/full/path/to/opcache.so &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using IIS you will need PHP 5.5 and you will need to add the extension for opcache under the &#039;&#039;ExtensionList&#039;&#039; section of the php.ini file. For PHP 5.3 and 5.4 you can download the binaries separately from [http://windows.php.net/downloads/pecl/releases/opcache] and you will also need to enter full absolute path to the module dll in php.ini.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code ini&amp;gt;&lt;br /&gt;
[ExtensionList]&lt;br /&gt;
...&lt;br /&gt;
zend_extension=php_opcache.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; max_accelerated_files&lt;br /&gt;
It is recommended above that opcache.max_accelerated_files should be set to 4000.&lt;br /&gt;
From: [http://php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files php.net max-accelerated-files]&lt;br /&gt;
*&#039;&#039;The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 } that is bigger than the configured value. Only numbers between 200 and 100000 are allowed.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Setting max_accelerated files to 4000 will allow 7963 PHP files to be cached in the hash table. While this may be suitable advice for many installations, there are approx. ~7000 PHP files in core moodle 2.7. If your version of moodle uses a bunch of non-core plugins, or if for any reasons your total number of cached PHP files in coverage is likely to exceed 7963, it would be worth increasing this number. I&#039;d suggest the default advice to be 8000 rather than 4000. (Or to actually use one of the numbers (-1) in the prime set above.)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]&lt;br /&gt;
* [http://windows.php.net/downloads/pecl/releases/opcache/ Windows builds for PHP 5.3-5.4]&lt;br /&gt;
&lt;br /&gt;
Forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=244133 OPcache: Memory Usage = 100% (is this good or bad?)]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=245885 OPCode cache]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Performance]]&lt;br /&gt;
&lt;br /&gt;
[[es:OPcache]]&lt;/div&gt;</summary>
		<author><name>Davidaylmer</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=Session_handling&amp;diff=112796</id>
		<title>Session handling</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=Session_handling&amp;diff=112796"/>
		<updated>2014-05-29T02:21:15Z</updated>

		<summary type="html">&lt;p&gt;Davidaylmer: /* Memcached */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server settings}}&lt;br /&gt;
An administrator can change the following settings in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Session Handling&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Once someone logs in to your Moodle server, the server starts a session. The session data allows the server to track users as they access different pages.&lt;br /&gt;
&lt;br /&gt;
==Use database for session information==&lt;br /&gt;
&lt;br /&gt;
Moodle needs to store the session data in some storage. By default either file or database session storage is selected, this option allows admin to change it. Large installation should use memcached driver described below.&lt;br /&gt;
&lt;br /&gt;
Note that this option disappears after setting the $CFG-&amp;gt;session_handler_class in config.php file.&lt;br /&gt;
&lt;br /&gt;
==Timeout==&lt;br /&gt;
&lt;br /&gt;
If users don&#039;t load a new page during the amount of time set here, Moodle will end their session and log them out.&lt;br /&gt;
&lt;br /&gt;
Be sure this time frame is long enough to cover the longest test your teachers may offer. If a student is logged out while they are taking a test, their responses to the test questions may be lost.&lt;br /&gt;
&lt;br /&gt;
==Cookie prefix==&lt;br /&gt;
&lt;br /&gt;
Most of the time, you can leave this blank, unless you are running more than one Moodle site on the same server. In this case, you will want to customize the name of the cookie each Moodle site uses to track the session. This enables you to be logged into more than one Moodle site at the same time.&lt;br /&gt;
&lt;br /&gt;
Note: If you change &amp;quot;Cookie prefix&amp;quot; or &amp;quot;Cookie path&amp;quot; you will need to login again as the changes take effect immediately.&lt;br /&gt;
&lt;br /&gt;
==Cookie path==&lt;br /&gt;
&lt;br /&gt;
The relative path to this Moodle installation, this may be used to force sending of Moodle session cookie to parent directories. Invalid values are ignored automatically.&lt;br /&gt;
&lt;br /&gt;
==Cookie domain==&lt;br /&gt;
&lt;br /&gt;
This can be used to send session cookies to higher domains instead of just the server domain. This may be useful for some SSO solutions. Invalid values are ignored automatically.&lt;br /&gt;
&lt;br /&gt;
==Session drivers==&lt;br /&gt;
User sessions may be stored in different backends. Session drivers can be configured only in config.php file - see examples in config-dist.php file.&lt;br /&gt;
&lt;br /&gt;
===Memcached===&lt;br /&gt;
Memcached session driver is the fastest driver, it requires external memcached server and memcached PHP extension. Server cluster nodes must use shared session storage.&lt;br /&gt;
&lt;br /&gt;
Configuration options in config.php:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;session_handler_class = &#039;\core\session\memcached&#039;;&lt;br /&gt;
$CFG-&amp;gt;session_memcached_save_path = &#039;127.0.0.1:11211&#039;;&lt;br /&gt;
$CFG-&amp;gt;session_memcached_prefix = &#039;memc.sess.key.&#039;;&lt;br /&gt;
$CFG-&amp;gt;session_memcached_acquire_lock_timeout = 120;&lt;br /&gt;
$CFG-&amp;gt;session_memcached_lock_expire = 7200;       // Ignored if memcached extension &amp;lt;= 2.1.0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* Make sure the memcached server has enough memory.&lt;br /&gt;
* Use different prefix when storing sessions from multiple Moodles in one server.&lt;br /&gt;
* If memcached extension &amp;lt;= 2.1.0 the locking works differently from other drivers, the lock is expired/released at the end of timeout - see MDL-42485.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For windows users, PHP.net only supplies binaries for memcache, (and not memcached). (http://windows.php.net/downloads/pecl/releases/)&lt;br /&gt;
&lt;br /&gt;
(As of 2.7, two different contribs exist for memcache session handling - see MDL-42011 - it seems the OU one doesn&#039;t use prefix/lock_expire for some reason... possibly better to use the catalyst patch, where the only difference to the above config.php is the spelling of memcache(d))&lt;br /&gt;
&lt;br /&gt;
===Files===&lt;br /&gt;
This driver is used by default in new installation.&lt;br /&gt;
&lt;br /&gt;
Configuration options in config.php:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;session_handler_class = &#039;\core\session\file&#039;;&lt;br /&gt;
$CFG-&amp;gt;session_file_save_path = $CFG-&amp;gt;dataroot.&#039;/sessions&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* File based sessions require file system that supports file locking.&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
This type of driver was used by default in Moodle 2.0-2.5&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;session_handler_class = &#039;\core\session\database&#039;;&lt;br /&gt;
$CFG-&amp;gt;session_database_acquire_lock_timeout = 120;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* DB sessions are not compatible with MyISAM database engine.&lt;br /&gt;
* If you are using MySQL/MariaDB make sure that \&#039;max_allowed_packet\&#039; in my.cnf (or my.ini) is at least 4M.&lt;br /&gt;
* The performance is relatively low, it is not recommended for large sites.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Sessions FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[cs:admin/setting/sessionhandling]]&lt;br /&gt;
[[ja:セッションハンドリング]]&lt;br /&gt;
[[de:Sitzungsinformationen]]&lt;/div&gt;</summary>
		<author><name>Davidaylmer</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=106171</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=106171"/>
		<updated>2013-07-25T12:34:58Z</updated>

		<summary type="html">&lt;p&gt;Davidaylmer: /* Using FreeTDS on Windows */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
Configure these settings in your created (and still empty) database:&lt;br /&gt;
:*Use a case sensitive collation, such as Latin1_General_CS_AS.&lt;br /&gt;
:*ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:*Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* (Moodle 2.x only) Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
:** This is not settable via the DB properties. To set READ_COMMITTED_SNAPSHOT, there must be no active connections to the database except for the connection executing the ALTER command. If you are viewing the DB in the Server Management Studio, disconnect from any servers in the &amp;quot;Object Explorer&amp;quot; (right-click &amp;gt; Disconnect), then create a &amp;quot;New Query&amp;quot; and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.&lt;br /&gt;
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Microsoft Drivers for SQL Server for PHP ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;WARNING: This driver has known problems and is therefore not suitable for any Moodle production servers.&#039;&#039;&#039;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server Driver for PHP. This is a PHP extension that allows PHP scripts to read and write data on Microsoft SQL Server databases and it overcomes the problems with the native SQL Server extension that was previously bundled with PHP.&lt;br /&gt;
&lt;br /&gt;
When using [[IIS]] it is strongly recommended to use the official Microsoft PHP installer from http://php.iis.net/, it should include the latest version of necessary drivers and it also simplifies future upgrades and configuration.&lt;br /&gt;
&lt;br /&gt;
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip Download!] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip FTP Download!] [http://www.sendspace.com/file/vtger3 Mirror]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20110906 patches || [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip Download!] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip FTP Download!] [http://www.sendspace.com/file/nkg2j4 Mirror]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.5.x (vc11) || Yes || 0.91.89 || [https://moodle.org/pluginfile.php/133/mod_forum/attachment/1012945/FreeTDS_0.91.89_PHP_5.5.x_%28vc11_ts_dblib%29.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.91.89 || [https://moodle.org/pluginfile.php/133/mod_forum/attachment/1012945/FreeTDS_0.91.89_PHP_5.5.x_%28vc11_nts_dblib%29.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to [[User:Alastair Hole|Alastair Hole]] for providing the PHP 5.3 builds of the libraries. Thanks to Enyby by providing the PHP 5.4 builds of the libraries. Thanks to David Aylmer for providing the PHP 5.5 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -&amp;gt; SQL Server Services&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu]. Do note that [http://www.freetds.org/news.html freeTDS] 0.91 was recently released, you can find latest versions [http://freetds.sourceforge.net/ here]. &lt;br /&gt;
&lt;br /&gt;
Note: the freetds.conf file you use should have &amp;quot;text size = 20971520&amp;quot; as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* FreeTDS for Windows is obsolete and too slow as of 2011. See: [http://moodle.org/mod/forum/discuss.php?d=183987 Hardware and Performance Forum]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Installing Postgres for PHP]]&lt;br /&gt;
* [[Using the Microsoft SQL Server Driver for PHP]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:SQL databases]]&lt;/div&gt;</summary>
		<author><name>Davidaylmer</name></author>
	</entry>
</feed>