https://docs.moodle.org/38/en/api.php?action=feedcontributions&user=Stronk7&feedformat=atomMoodleDocs - User contributions [en]2024-03-29T07:55:16ZUser contributionsMediaWiki 1.39.6https://docs.moodle.org/38/en/index.php?title=Upgrading&diff=132613Upgrading2018-12-03T00:49:37Z<p>Stronk7: reorganize the section to avoid duplicating incomplete information. Always refer to the release notes for server and client requirements.</p>
<hr />
<div>{{Installing Moodle}} <br />
''This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].''<br />
<br />
==Check the requirements==<br />
<br />
Before upgrading, check that your server meets all requirements for {{Version}} in ''Administration > Site administration > Server > [[Environment]]''. <br />
<br />
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.<br />
<br />
Notes:<br />
<br />
* You can only upgrade to Moodle {{Version}} from Moodle 3.1 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/31/en/Upgrading_to_Moodle_3.1 upgrade to 3.1] as a first step.<br />
<br />
==Before upgrading==<br />
<br />
'''We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.'''<br />
<br />
Consider setting the [[Upgrade key|upgrade key]] for your site.<br />
<br />
== Backup important data ==<br />
<br />
There are three areas that should be backed up before any upgrade:<br />
#Moodle software (For example, everything in server/htdocs/moodle)<br />
#Moodle uploaded files (For example, server/moodledata)<br />
#Moodle database (For example, your Postgres or MySQL database dump)<br />
<br />
See [[Site backup]] for more specific information.<br />
<br />
== Check for plugin updates ==<br />
<br />
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.<br />
<br />
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).<br />
<br />
The upgrade of the plugin will then happen as part of the Moodle upgrade process.<br />
<br />
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.<br />
<br />
==Put your site into maintenance mode==<br />
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.<br />
<br />
== Install the new Moodle software ==<br />
You can fetch the current version of the software through <br />
<br />
wget http://sourceforge.net/projects/moodle/files/Moodle/stable{{Version2}}/moodle-latest-{{Version2}}.tgz<br />
<br />
=== Standard install package ===<br />
<br />
# Move your old Moodle software program files to another location. ''Do NOT copy new files over the old files.''<br />
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.<br />
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. <br />
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)<br />
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it. Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder. If you are moving your installation to a new server or new location on your server, then you will need to follow the Migration documents.<br />
<br />
====Linux====<br />
mv moodle moodle.backup<br />
tar xvzf moodle-{{Version}}.tgz<br />
<br />
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one ('''check that custom plugins are the correct version for your new Moodle first'''):<br />
<br />
cp moodle.backup/config.php moodle<br />
cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme<br />
cp -pr moodle.backup/mod/mymod moodle/mod/mymod<br />
<br />
Don't forget to make moodle/config.php (and the rest of the source code) readable by your www server. Ideally the files should not be writeable by your server.<br />
<br />
chown -R www-data:www-data moodle (Linux debian - change to appropriate user and group for your OS version)<br />
chmod -R 755 moodle<br />
<br />
If you use cron, take care that cron.php is executeable and uses the correct php command: <br />
chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)<br />
copy the first line from cron.php (if it looks like '#!/usr/local/bin/php' or '#!/usr/local/bin/php5.3', no need to copy '<?php') <br />
if necessary. However, for a simple upgrade, there should be no need to change anything with cron.<br />
<br />
=== Using Git ===<br />
<br />
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.<br />
<br />
===Command line upgrade===<br />
<br />
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.<br />
<br />
== Finishing the upgrade ==<br />
<br />
The last step is to trigger the upgrade processes within Moodle. <br />
<br />
If you put your site into Maintenance mode earlier; take it out now!<br />
<br />
To do this just go to ''Administration > Site administration > Notifications''.<br />
<br />
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can't do itself (very rare) then you will see messages telling you what you need to do.<br />
<br />
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!<br />
<br />
Note: If you are running multiple servers then you should purge all caches manually (via ''Administration > Site administration > Development > Purge all caches'') after completing the upgrade on all servers.<br />
<br />
===Fatal error: Maximum execution time of 30 seconds exceeded...===<br />
<br />
If your server uses a main language other than English, you may encounter a 'Fatal error: Maximum execution time of 30 seconds exceeded' when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a succcessful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.<br />
<br />
==After upgrading==<br />
<br />
The config.php file from your installation should work fine but if you take a look at config-dist.php that came with Moodle 3.0 there are more/different options available (e.g. database drivers and settings). It's a good idea to map your old config.php settings to a new one based on the 3.0 config-dist.php.<br />
<br />
===Cron===<br />
<br />
Cron has received a major update (MDL-25499) and now has support for both scheduled and ad hoc tasks.<br />
<br />
The benefits of these changes are:<br />
* The schedule for every task can be configured by the admin<br />
* Tasks can run in parallel<br />
* Cron processes use locking to prevent the same task running at the same time by different processes<br />
* Clusters with multiple identical application nodes are supported, you can run cron on all of them<br />
<br />
A result of this is that cron can be run much more often, which means (for example) forum posts can be sent out sooner. To take advantage of the new cron system it is now strongly recommended that administrators increase the frequency that cron is run to at least ''once per minute''.<br />
<br />
You also may need to modify any automated scripts you have that are parsing the output from cron. It is no longer possible to simply monitor the output of cron for the string "Cron script completed correctly" (if that is what you were doing). An alternative is to monitor the output for the string "task failed:". If you detect that a task is failing, [[Cron#Debugging_Scheduled_Tasks|here]] are some tips for debugging the failure. <br />
<br />
Before the upgrade, there may have been a cron task that was failing, which was preventing the rest of cron from being executed. A failure in any single task will no longer prevent the rest of the Moodle cron tasks from executing, so you may uncover previously masked bugs. It is a good idea to closely monitor the output from cron after the upgrade.<br />
<br />
===Assignments===<br />
<br />
The old assignment (2.2) module has been removed from core and has been replaced by a stub to support transparently remapping URLs and restoring course backups from the old module to the new one. <br />
<br />
If you are still using the old assignment (2.2) module, after upgrading to Moodle 3.0 all assignment (2.2) activities will be hidden. You need to run the [[Assignment upgrade tool]] to un-hide the activities.<br />
<br />
If you really, really need to keep using the old assignment (2.2) module, you should update the code to Moodle 3.0, and then replace the "mod/assignment" folder with the one from https://github.com/moodlehq/moodle-mod_assignment/releases before completing the upgrade.<br />
<br />
==Possible issues that may affect you in Moodle {{Version}}==<br />
<br />
* To use 'Run now' links in [[Scheduled tasks]], you need to set 'Path to PHP CLI' (pathtophp) in Site administration > Server > System paths.<br />
<br />
''Items to be added...''<br />
<br />
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. <br />
<br />
=== Moodle 3.1, 3.2, 3.3, 3.4 and 3.5 improvements ===<br />
<br />
Depending on which version you are upgrading from, please see the section 'Possible issues that may affect you' in the documentation<br />
<br />
* [https://docs.moodle.org/31/en/Upgrading Upgrading to Moodle 3.1]<br />
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]<br />
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]<br />
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]<br />
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]<br />
<br />
==See also==<br />
<br />
* [[Installation]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation help forum] <br />
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]<br />
<br />
[[es:Actualización de moodle]]<br />
[[fr:Mise à jour]]<br />
[[ja:Moodleをアップグレードする]]<br />
[[de:Aktualisierung von Moodle]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Upgrading&diff=132376Upgrading2018-11-25T12:28:24Z<p>Stronk7: Add a note about PHP 7.3 being work in progress.</p>
<hr />
<div>{{Installing Moodle}} <br />
''This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].''<br />
<br />
==Check the requirements==<br />
<br />
Check that your server meets all requirements for {{Version}} in ''Administration > Site administration > Server > [[Environment]]''. <br />
<br />
See the [{{Release notes}} release notes] in the dev docs for software requirements.<br />
<br />
Notes:<br />
<br />
* You can only upgrade to Moodle {{Version}} from Moodle 3.1 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/31/en/Upgrading_to_Moodle_3.1 upgrade to 3.1] as a first step.<br />
* The minimum PHP version has increased and is now 7.0.0. PHP 7.3 support is being implemented (MDL-63420) for Moodle 3.6.x and later releases. Hence it's still incomplete and only for development purposes.<br />
* The PHP extension '''intl''' is now required in Moodle 3.4 (previously it was only recommended).<br />
<br />
==Before upgrading==<br />
<br />
'''We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.'''<br />
<br />
Consider setting the [[Upgrade key|upgrade key]] for your site.<br />
<br />
== Backup important data ==<br />
<br />
There are three areas that should be backed up before any upgrade:<br />
#Moodle software (For example, everything in server/htdocs/moodle)<br />
#Moodle uploaded files (For example, server/moodledata)<br />
#Moodle database (For example, your Postgres or MySQL database dump)<br />
<br />
See [[Site backup]] for more specific information.<br />
<br />
== Check for plugin updates ==<br />
<br />
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.<br />
<br />
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).<br />
<br />
The upgrade of the plugin will then happen as part of the Moodle upgrade process.<br />
<br />
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.<br />
<br />
==Put your site into maintenance mode==<br />
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.<br />
<br />
== Install the new Moodle software ==<br />
You can fetch the current version of the software through <br />
<br />
wget http://sourceforge.net/projects/moodle/files/Moodle/stable{{Version2}}/moodle-latest-{{Version2}}.tgz<br />
<br />
=== Standard install package ===<br />
<br />
# Move your old Moodle software program files to another location. ''Do NOT copy new files over the old files.''<br />
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.<br />
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. <br />
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)<br />
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it. Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder. If you are moving your installation to a new server or new location on your server, then you will need to follow the Migration documents.<br />
<br />
====Linux====<br />
mv moodle moodle.backup<br />
tar xvzf moodle-{{Version}}.tgz<br />
<br />
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one ('''check that custom plugins are the correct version for your new Moodle first'''):<br />
<br />
cp moodle.backup/config.php moodle<br />
cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme<br />
cp -pr moodle.backup/mod/mymod moodle/mod/mymod<br />
<br />
Don't forget to make moodle/config.php (and the rest of the source code) readable by your www server. Ideally the files should not be writeable by your server.<br />
<br />
chown -R www-data:www-data moodle (Linux debian - change to appropriate user and group for your OS version)<br />
chmod -R 755 moodle<br />
<br />
If you use cron, take care that cron.php is executeable and uses the correct php command: <br />
chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)<br />
copy the first line from cron.php (if it looks like '#!/usr/local/bin/php' or '#!/usr/local/bin/php5.3', no need to copy '<?php') <br />
if necessary. However, for a simple upgrade, there should be no need to change anything with cron.<br />
<br />
=== Using Git ===<br />
<br />
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.<br />
<br />
===Command line upgrade===<br />
<br />
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.<br />
<br />
== Finishing the upgrade ==<br />
<br />
The last step is to trigger the upgrade processes within Moodle. <br />
<br />
If you put your site into Maintenance mode earlier; take it out now!<br />
<br />
To do this just go to ''Administration > Site administration > Notifications''.<br />
<br />
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can't do itself (very rare) then you will see messages telling you what you need to do.<br />
<br />
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!<br />
<br />
Note: If you are running multiple servers then you should purge all caches manually (via ''Administration > Site administration > Development > Purge all caches'') after completing the upgrade on all servers.<br />
<br />
===Fatal error: Maximum execution time of 30 seconds exceeded...===<br />
<br />
If your server uses a main language other than English, you may encounter a 'Fatal error: Maximum execution time of 30 seconds exceeded' when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a succcessful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.<br />
<br />
==After upgrading==<br />
<br />
The config.php file from your installation should work fine but if you take a look at config-dist.php that came with Moodle 3.0 there are more/different options available (e.g. database drivers and settings). It's a good idea to map your old config.php settings to a new one based on the 3.0 config-dist.php.<br />
<br />
===Cron===<br />
<br />
Cron has received a major update (MDL-25499) and now has support for both scheduled and ad hoc tasks.<br />
<br />
The benefits of these changes are:<br />
* The schedule for every task can be configured by the admin<br />
* Tasks can run in parallel<br />
* Cron processes use locking to prevent the same task running at the same time by different processes<br />
* Clusters with multiple identical application nodes are supported, you can run cron on all of them<br />
<br />
A result of this is that cron can be run much more often, which means (for example) forum posts can be sent out sooner. To take advantage of the new cron system it is now strongly recommended that administrators increase the frequency that cron is run to at least ''once per minute''.<br />
<br />
You also may need to modify any automated scripts you have that are parsing the output from cron. It is no longer possible to simply monitor the output of cron for the string "Cron script completed correctly" (if that is what you were doing). An alternative is to monitor the output for the string "task failed:". If you detect that a task is failing, [[Cron#Debugging_Scheduled_Tasks|here]] are some tips for debugging the failure. <br />
<br />
Before the upgrade, there may have been a cron task that was failing, which was preventing the rest of cron from being executed. A failure in any single task will no longer prevent the rest of the Moodle cron tasks from executing, so you may uncover previously masked bugs. It is a good idea to closely monitor the output from cron after the upgrade.<br />
<br />
===Assignments===<br />
<br />
The old assignment (2.2) module has been removed from core and has been replaced by a stub to support transparently remapping URLs and restoring course backups from the old module to the new one. <br />
<br />
If you are still using the old assignment (2.2) module, after upgrading to Moodle 3.0 all assignment (2.2) activities will be hidden. You need to run the [[Assignment upgrade tool]] to un-hide the activities.<br />
<br />
If you really, really need to keep using the old assignment (2.2) module, you should update the code to Moodle 3.0, and then replace the "mod/assignment" folder with the one from https://github.com/moodlehq/moodle-mod_assignment/releases before completing the upgrade.<br />
<br />
==Possible issues that may affect you in Moodle {{Version}}==<br />
<br />
* To use 'Run now' links in [[Scheduled tasks]], you need to set 'Path to PHP CLI' (pathtophp) in Site administration > Server > System paths.<br />
<br />
''Items to be added...''<br />
<br />
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. <br />
<br />
=== Moodle 3.1, 3.2, 3.3, 3.4 and 3.5 improvements ===<br />
<br />
Depending on which version you are upgrading from, please see the section 'Possible issues that may affect you' in the documentation<br />
<br />
* [https://docs.moodle.org/31/en/Upgrading Upgrading to Moodle 3.1]<br />
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]<br />
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]<br />
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]<br />
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]<br />
<br />
==See also==<br />
<br />
* [[Installation]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation help forum] <br />
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]<br />
<br />
[[es:Actualización de moodle]]<br />
[[fr:Mise à jour]]<br />
[[ja:Moodleをアップグレードする]]<br />
[[de:Aktualisierung von Moodle]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Upgrading&diff=131339Upgrading2018-07-01T22:13:09Z<p>Stronk7: Add a note in upgrade about the new PostgreSQL default behavior in 3.5 and up.</p>
<hr />
<div>{{Installing Moodle}} <br />
''This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].''<br />
<br />
==Check the requirements==<br />
<br />
Check that your server meets all requirements for {{Version}} in ''Administration > Site administration > Server > [[Environment]]''. <br />
<br />
See the [{{Release notes}} release notes] in the dev docs for software requirements.<br />
<br />
Notes:<br />
<br />
* You can only upgrade to Moodle {{Version}} from Moodle 3.1 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/31/en/Upgrading_to_Moodle_3.1 upgrade to 3.1] as a first step.<br />
* The minimum PHP version has increased and is now 7.0.0.<br />
* The PHP extension '''intl''' is now required in Moodle 3.4 (previously it was only recommended).<br />
<br />
==Before upgrading==<br />
<br />
'''We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.'''<br />
<br />
Consider setting the [[Upgrade key|upgrade key]] for your site.<br />
<br />
== Backup important data ==<br />
<br />
There are three areas that should be backed up before any upgrade:<br />
#Moodle software (For example, everything in server/htdocs/moodle)<br />
#Moodle uploaded files (For example, server/moodledata)<br />
#Moodle database (For example, your Postgres or MySQL database dump)<br />
<br />
See [[Site backup]] for more specific information.<br />
<br />
== Check for plugin updates ==<br />
<br />
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.<br />
<br />
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).<br />
<br />
The upgrade of the plugin will then happen as part of the Moodle upgrade process.<br />
<br />
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.<br />
<br />
==Put your site into maintenance mode==<br />
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.<br />
<br />
== Install the new Moodle software ==<br />
You can fetch the current version of the software through <br />
<br />
wget http://sourceforge.net/projects/moodle/files/Moodle/stable{{Version2}}/moodle-latest-{{Version2}}.tgz<br />
<br />
=== Standard install package ===<br />
<br />
# Move your old Moodle software program files to another location. ''Do NOT copy new files over the old files.''<br />
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.<br />
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. <br />
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)<br />
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it. Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder. If you are moving your installation to a new server or new location on your server, then you will need to follow the Migration documents.<br />
<br />
====Linux====<br />
mv moodle moodle.backup<br />
tar xvzf moodle-{{Version}}.tgz<br />
<br />
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one ('''check that custom plugins are the correct version for your new Moodle first'''):<br />
<br />
cp moodle.backup/config.php moodle<br />
cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme<br />
cp -pr moodle.backup/mod/mymod moodle/mod/mymod<br />
<br />
Don't forget to make moodle/config.php (and the rest of the source code) readable by your www server. Ideally the files should not be writeable by your server.<br />
<br />
chown -R www-data:www-data moodle (Linux debian - change to appropriate user and group for your OS version)<br />
chmod -R 755 moodle<br />
<br />
If you use cron, take care that cron.php is executeable and uses the correct php command: <br />
chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)<br />
copy the first line from cron.php (if it looks like '#!/usr/local/bin/php' or '#!/usr/local/bin/php5.3', no need to copy '<?php') <br />
if necessary. However, for a simple upgrade, there should be no need to change anything with cron.<br />
<br />
=== Using Git ===<br />
<br />
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.<br />
<br />
===Command line upgrade===<br />
<br />
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.<br />
<br />
== Finishing the upgrade ==<br />
<br />
The last step is to trigger the upgrade processes within Moodle. <br />
<br />
If you put your site into Maintenance mode earlier; take it out now!<br />
<br />
To do this just go to ''Administration > Site administration > Notifications''.<br />
<br />
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can't do itself (very rare) then you will see messages telling you what you need to do.<br />
<br />
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!<br />
<br />
Note: If you are running multiple servers then you should purge all caches manually (via ''Administration > Site administration > Development > Purge all caches'') after completing the upgrade on all servers.<br />
<br />
===Fatal error: Maximum execution time of 30 seconds exceeded...===<br />
<br />
If your server uses a main language other than English, you may encounter a 'Fatal error: Maximum execution time of 30 seconds exceeded' when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a succcessful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.<br />
<br />
==After upgrading==<br />
<br />
The config.php file from your installation should work fine but if you take a look at config-dist.php that came with Moodle 3.0 there are more/different options available (e.g. database drivers and settings). It's a good idea to map your old config.php settings to a new one based on the 3.0 config-dist.php.<br />
<br />
===Cron===<br />
<br />
Cron has received a major update (MDL-25499) and now has support for both scheduled and ad hoc tasks.<br />
<br />
The benefits of these changes are:<br />
* The schedule for every task can be configured by the admin<br />
* Tasks can run in parallel<br />
* Cron processes use locking to prevent the same task running at the same time by different processes<br />
* Clusters with multiple identical application nodes are supported, you can run cron on all of them<br />
<br />
A result of this is that cron can be run much more often, which means (for example) forum posts can be sent out sooner. To take advantage of the new cron system it is now strongly recommended that administrators increase the frequency that cron is run to at least ''once per minute''.<br />
<br />
You also may need to modify any automated scripts you have that are parsing the output from cron. It is no longer possible to simply monitor the output of cron for the string "Cron script completed correctly" (if that is what you were doing). An alternative is to monitor the output for the string "task failed:". If you detect that a task is failing, [[Cron#Debugging_Scheduled_Tasks|here]] are some tips for debugging the failure. <br />
<br />
Before the upgrade, there may have been a cron task that was failing, which was preventing the rest of cron from being executed. A failure in any single task will no longer prevent the rest of the Moodle cron tasks from executing, so you may uncover previously masked bugs. It is a good idea to closely monitor the output from cron after the upgrade.<br />
<br />
===Assignments===<br />
<br />
The old assignment (2.2) module has been removed from core and has been replaced by a stub to support transparently remapping URLs and restoring course backups from the old module to the new one. <br />
<br />
If you are still using the old assignment (2.2) module, after upgrading to Moodle 3.0 all assignment (2.2) activities will be hidden. You need to run the [[Assignment upgrade tool]] to un-hide the activities.<br />
<br />
If you really, really need to keep using the old assignment (2.2) module, you should update the code to Moodle 3.0, and then replace the "mod/assignment" folder with the one from https://github.com/moodlehq/moodle-mod_assignment/releases before completing the upgrade.<br />
<br />
==Possible issues that may affect you in Moodle {{Version}}==<br />
<br />
* 'Site policies' in the Site administration has been renamed '[[Site security settings]]'.<br />
<br />
* Moodle presets have changed. Most of the Bootstrap 4 variables have changed and the way bootstrap, font awesome and core scss is included. For more info on the Bootstrap 4 changes visit https://getbootstrap.com/docs/4.0/migration/<br />
<code php><br />
// Example code, place scss variables here.<br />
// $font-size-base: 0.9375rem<br />
<br />
// Import FontAwesome.<br />
@import "fontawesome";<br />
<br />
// Import All of Bootstrap.<br />
@import "bootstrap";<br />
<br />
// Import Core moodle CSS.<br />
@import "moodle";<br />
<br />
// Example code, place scss using Bootstrap mixins and extends here.<br />
// .navbar {<br />
// @include shadow();<br />
// }<br />
</code><br />
<br />
* The PostgreSQL driver has been improved and, now, the <tt>get_recordset_xxx()</tt> operations don't fetch all the records into memory for big (>100000) datasets. This can be configured or disabled using the new <tt>fetchbuffersize</tt> [https://github.com/moodle/moodle/blob/f61ee4e857a894a5b8b69516b00be88ae499964b/config-dist.php#L73 dboption]. Note this is known to affect installations using pg_bouncer in transaction mode. See MDL-60174 for more information.<br />
<br />
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.5%22)%20AND%20labels%20%3D%20ui_change%20 issues fixed in Moodle 3.5 which are labelled ui_change]. <br />
<br />
=== Moodle 3.1, 3.2, 3.3 and 3.4 improvements ===<br />
<br />
Depending on which version you are upgrading from, please see the section 'Possible issues that may affect you' in the documentation<br />
<br />
* [https://docs.moodle.org/31/en/Upgrading Upgrading to Moodle 3.1]<br />
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]<br />
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]<br />
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]<br />
<br />
==See also==<br />
<br />
* [[Installation]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation help forum] <br />
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]<br />
<br />
[[es:Actualización de moodle]]<br />
[[fr:Mise à jour]]<br />
[[ja:Moodleをアップグレードする]]<br />
[[de:Aktualisierung von Moodle]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=131076Complete install packages for Windows2018-05-19T18:50:12Z<p>Stronk7: typo</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)]. This must be the '''vc_redist.x86.exe''' download as the PHP build is 32-bit.<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
:''NOTE:'' If you will be installing a server with a language other than English, the install process will need to download the corresponding language pack, which will take some time, and you will likely get a script timeout error. To prevent this, you will need to edit the server/php/php.ini file and change the line that has 'max_execution_time = 30' into 'max_execution_time = 600'.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server is installed. All the checks should pass as far as the [[#System_requirements|system requirements]] have been fulfilled. <br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[Authentication|authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=131075Complete install packages for Windows2018-05-19T18:44:16Z<p>Stronk7: remember system requirements</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)]. This must be the '''vc_redist.x86.exe''' download as the PHP build is 32-bit.<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
:''NOTE:'' If you will be installing a server with a language other than English, the install process will need to download the corresponding language pack, which will take some time, and you will likely get a script timeout error. To prevent this, you will need to edit the server/php/php.ini file and change the line that has 'max_execution_time = 30' into 'max_execution_time = 600'.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed. All the checks should pass as far as the [[#System_requirements|system requirements]] have been fulfilled. <br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[Authentication|authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=129734Complete install packages for Windows2017-12-27T01:10:04Z<p>Stronk7: MDLSITE-4964 - phpmyadmin does not come with moodle windows installers since ages ago. Deleting any reference to it.</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)].<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
:''NOTE:'' If you will be installing a server with a language other than English, the install process will need to download the corresponding language pack, which will take some time, and you will likely get a script timeout error. To prevent this, you will need to edit the server/php/php.ini file and change the line that has 'max_execution_time = 30' into 'max_execution_time = 600'.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[Authentication|authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=admin/environment/custom_check/site_not_https&diff=127404admin/environment/custom check/site not https2017-04-17T14:33:52Z<p>Stronk7: Stronk7 moved page admin/environment/custom check/check is https to admin/environment/custom check/site not https without leaving a redirect: because I've changed the name of the environment check in MDL-54901</p>
<hr />
<div>#Redirect[[Transitioning to HTTPS]]<br />
<br />
[[es:HTTPS]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=admin/environment/custom_check/site_not_https&diff=127403admin/environment/custom check/site not https2017-04-17T12:10:52Z<p>Stronk7: WIP on https://tracker.moodle.org/browse/MDL-54901 ...</p>
<hr />
<div>#Redirect[[Transitioning to HTTPS]]<br />
<br />
[[es:HTTPS]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=admin/environment/custom_check/check_ssl_wwwroot&diff=127402admin/environment/custom check/check ssl wwwroot2017-04-17T11:57:34Z<p>Stronk7: I really think that HTTPS was a better target, but as far as we have wgMaxRedirects = 1, cannot get multiple redirects working, it seems. So straight redirecting here.</p>
<hr />
<div>#Redirect[[Transitioning to HTTPS]]<br />
<br />
[[es:HTTPS]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=admin/environment/custom_check/check_ssl_wwwroot&diff=127401admin/environment/custom check/check ssl wwwroot2017-04-17T11:51:19Z<p>Stronk7: Working on MDL-54901 ... testing ...</p>
<hr />
<div>#Redirect[[HTTPS]]<br />
<br />
[[es:HTTPS]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125450Complete install packages for Windows2016-09-27T10:08:25Z<p>Stronk7: /* Vista and Windows 7/8/10 */</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)].<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
{{New features}}<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125449Complete install packages for Windows2016-09-27T09:48:17Z<p>Stronk7: /* Vista and Windows 7/8/10 */</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)].<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
{{Moodle 3.1}}<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125448Complete install packages for Windows2016-09-27T09:44:48Z<p>Stronk7: Adding some more links to apachefrieds, bitnami, moodlecloud</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [https://download.moodle.org/windows/ Windows download page] and also from [https://bitnami.com/stacks Bitnami stacks]. The packages are designed for new installations on a standalone computer. All them use the popular [https://www.apachefriends.org/ XAMPP Apache Friends packages]. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)].<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle-ready alternatives [https://moodlecloud.com out there].<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125447Complete install packages for Windows2016-09-27T09:27:29Z<p>Stronk7: Added MVC++ resdistributable requirement and links</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [http://download.moodle.org/windows/ Windows download page] and from bitnami (for newer Windows versions). The packages are designed for new installations on a standalone computer. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
:**Microsoft Visual C++ 2015 Redistributable package is required for PHP ([https://www.microsoft.com/en-us/download/details.aspx?id=48145 download link)].<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Requirements and Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the [https://tracker.moodle.org Moodle Tracker], so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle packaged alternatives out there.<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125446Complete install packages for Windows2016-09-27T09:22:50Z<p>Stronk7: new packages supporting vista and later available</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [http://download.moodle.org/windows/ Windows download page] and from bitnami (for newer Windows versions). The packages are designed for new installations on a standalone computer. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
Packages generated for Moodle 3.1 and later versions should work with Vista/7/8/10 out of the box. They include PHP 7 and MariaDB instead of MySQL, resulting in a smoother experience than previous versions of the packages.<br />
<br />
People facing problems with the new packages should:<br />
<br />
:* Read the Troubleshooting information, both here and in the package's README.txt file.<br />
:* Report any consistent problem in the Moodle Tracker, so it can be investigated and, hopefully, fixed.<br />
:* Consider installing a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a windows or linux LAMP stack and then install Moodle there.<br />
:* Use other Moodle packaged alternatives out there.<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Complete_install_packages_for_Windows&diff=125445Complete install packages for Windows2016-09-27T09:11:59Z<p>Stronk7: updating requirements for 3.1 and up</p>
<hr />
<div>{{Installing Moodle}}<br />
Complete install packages are available from Moodle.org's [http://download.moodle.org/windows/ Windows download page] and from bitnami (for newer Windows versions). The packages are designed for new installations on a standalone computer. The complete install package can be used on a server, but '''it is not recommended that it be used as a production site'''. Please note Moodle.org's [http://download.moodle.org Standard install packages] only contain the Moodle code.<br />
<br />
This document provides instructions for using the Windows packages. Separate instructions are available for [[Complete Install Packages for Mac OS X|Mac OS X packages]].<br />
<br />
The complete install packages allow Moodle to be installed, along with the prerequisites that includes a web server, Apache, database, MySQL, scripting language, PHP, an administration tool, phpMyAdmin and Moodle all wrapped in the Xampp-lite shell. Several versions of the complete install package are available. The instructions on the download page provide guidance on which version is likely to be most suitable.<br />
<br />
In short, complete install packages are designed to create a matched webserver and Moodle site on a standalone computer with minimal effort. <br />
<br />
==System requirements==<br />
:*256 MB RAM (minimum), 1GB RAM (recommended)<br />
:*500 MB free Fixed Disk (more space will be needed depending on user uploads)<br />
:* For old versions of Moodle:<br />
:**Windows 98/ME (minimum)<br />
:**Windows NT/2000/XP/2003 (recommended)<br />
:* For Moodle 3.1 and later versions:<br />
:**Windows Vista/7/8/10/2008/2012<br />
<br />
===Port 80 Conflict if Skype is already installed===<br />
As the Moodle Windows package uses the same port (80) as [http://www.skype.com/en/ Skype] does, it will not work if the computer has Skype already installed.<br />
<br />
The fix is very simple: Exit Skype (don't just close the window), then start the Moodle Windows package. Once Moodle for Windows is running, it should be safe to start Skype again. If the local Moodle is using the port 80, Skype will automatically select a different port when it is run.<br />
<br />
===Vista and Windows 7/8/10===<br />
<br />
* Many people have trouble installing the packages for Windows on Vista and Windows 7, 8 and 10.<br />
* Some people had previously used the packages in Windows 7 and reported that they no longer work under Windows 10. You only have one month to uninstall the Windows 10 upgrade!<br />
* There seems to be a problem with the enclosed XAMPP package and the Windows OSes, and trying to use the compatibilty settings of Windows does not work.<br />
* You can install a virtual machine (eg, [https://www.virtualbox.org/ VirtualBox]) with a Windows 7 guest, or a more solid Linux guest !<br />
<br />
One simple solution is to use http://bitnami.org/stack/moodle (from amazon.com).<br />
<br />
==Install complete package process==<br />
The complete install package is a zip file that contains a webserver called [[Apache]], plus Moodle and Moodle's required [[MySQL]] database and [[PHP]] program. <br />
<br />
There are three basic parts to the this install process. <br />
#Download and unpack the complete install package. <br />
#Start the webserver. <br />
#Install Moodle using a web browser.<br />
<br />
===First create file structure===<br />
====Download the package====<br />
[http://download.moodle.org/windows Download Windows] packed-zip file from Moodle.<br />
[[Image:Moodle Setup zipfile.jpg|frame|center|A downloaded complete install package Windows 1.9 zip file in Windows Explorer]]<br />
<br />
====Unpack the package====<br />
Unpack (extract files by clicking on) the zip file you downloaded to a drive or partition of your choice. The extract process will create three files ("Start Moodle", "Stop Moodle", and "README") and a subfolder called "server". <br />
*Do NOT rename the "server" subfolder <br />
:''Note:'' There will also be a folder under this server subfolder, called \moodle that holds the Moodle program.<br />
<br />
:''TIP:'' Create a folder and extract the files there. For example, you might have one folder called Moodle254 and another one called Moodle281 for different versions or purposes.<br />
<br />
:''TIP:'' Make path to "server" subfolder simple. Best way if it will be in drive root. Like "D:\moodle281\server". A long path, especially with any strange symbols, can prevent XAMPP from working properly.<br />
<br />
===Second - start the webserver===<br />
Now you are ready to start the webserver. Use the "Start Moodle.exe" file which you should find in the top directory. Once the "Start Moodle.exe" program is open, don't close it; use "Stop Moodle.exe" for that purpose.<br />
<br />
:''Note:'' These programs control both Apache and MySQL programs that operate the webserver. Some sites will individually start and stop Apache and MySQL with the Xampp bat files found in the "server" subfolder.<br />
<br />
:''Tip:'' Alternatively, on a standalone computer with several potential webservers that might be running, you can use the "xampp_restart.exe" file in the "server" subfolder.<br />
<br />
:''Tip:'' You can also add shortcuts to the commands that start and stop the site in your Windows "start" menu.<br />
<br />
Now you are ready to start the Moodle installation.<br />
<br />
:''Warning:'' Windows XP requires the msvcr71.dll library file in order to run Xampp. Installing the [http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en .Net 1.1 framework] (not .Net 2.0 and upper) could resolve it. You can also search for the file on Google, download it and copy it into the server/apache/bin folder.<br />
<br />
===Third - start Moodle installation===<br />
Start your web browser and type <nowiki> localhost, or http://127.0.0.1 or http://localhost </nowiki>in the address bar. You will either start your first time Moodle installation or if it is already installed you will enter the Moodle site's [[Front Page]] or Login screen.<br />
<br />
[[Image:Moodle_Setup_localhost_browser.jpg|frame|center|A browser's addressbar showing "localhost". Click on the green Goto arrow will go to the installed Moodle site.]]<br />
<br />
:''Tip:'' After Moodle installs, put the site in your "favorites" or as a "bookmark" in you browser.<br />
<br />
====Set language====<br />
The initial install page will be displayed after you type "localhost".<br />
<br />
[[Image:C Install Windows 1.png|thumb|center|600px|Set initial language]]<br />
<br />
*Choose your preferred language (English is used in this example) and click the “Next” button.<br />
<br />
====Diagnostic results====<br />
A diagnostic report is displayed – hopefully it will look like this, if not you may need to address some issues.<br />
[[Image:Complete Windows Install 2.png|thumb|center|546px|Moodle liked and gave a Pass ]]<br />
<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Moodle paths====<br />
The paths for your Moodle installation are shown – if you are only using this as a local testing server, accept the ones that are shown on your screen.<br />
<br />
What you enter in the "Web Address" field depends on what you intend to use the new Moodle installation for. <br />
If you are just going to use it for local testing, then use 'http://localhost'. <br />
If you are going to test the new installation on a LAN, and will be accessing it from other machines on that LAN, then put the private IP address or network name of the serving machine, followed by a forward slash and moodle: Web Address - http://192.168.1.1/moodle<br />
If you are going to test the installation on the internet, then you will need to put the public ip address followed by a forward slash and moodle: http://your_ip_address/moodle or you can put your domain name here instead.<br />
<br />
[[image:Complete install Windows 3.png|thumb|center|600px|Installation paths]]<br />
<br />
*Click the “Next” button to continue.<br />
<br />
====Database configuration====<br />
*In the next fields, we enter the database settings. The fields are populated with some suggested values.<br />
<br />
*We strongly recommend you place a user name and password in this screen. (Don't forget them).<br />
<br />
*DO NOT USE THE “ROOT” USER WITHOUT A PASSWORD FOR PRODUCTION INSTALLATIONS AS THIS CREATES A SECURITY VULNERABILITY<br />
[[image:Complete install Windows 4.png|thumb|center|535px|Installation's database settings]]<br />
<br />
*When the fields have been populated, click the “Next” button to continue.<br />
<br />
====Check server====<br />
The install process checks the server it installed.<br />
[[image:Complete install Windows 5.png|thumb|center|535px|Check server environment screen]]<br />
*Click the “Next” button to continue.<br />
<br />
====Confirm initial language pack====<br />
Moodle will now check to see if the language pack is available for the language you selected at the first step. If it is not, Moodle will continue with the install in English.<br />
[[image:Complete install Windows 6.png|thumb|center|535px|Language pack check]]<br />
<br />
====Confirm config.php====<br />
Provided the Moodle folder is writable, a message confirming the configuration has been completed will be displayed.<br />
[[image:Complete install Windows 7.png|thumb|center|549px|Confirmation that config.php has been created]]<br />
<br />
*Click the “ Continue” button to proceed.<br />
<br />
====Moodle copyright & agreement====<br />
The Moodle copyright / license notices are displayed.<br />
<br />
[[image:Complete install Windows 8.png|thumb|center|400px|Copyright notice and agreement]]<br />
<br />
*Click the “Yes” button to continue. <br />
<br />
====Current release and unattended option====<br />
The current release information is shown. <br />
'''Check off the unattended operations box'''. This will automatically advance through many screens. If you would like to watch the install screen by screen, do not check this box and be prepared to press the "continute button" many times.<br />
<br />
*Click the "Continue" button and wait.<br />
[[Image:Complete install Windows 9.png|thumb|center|600px|Current release and "unattended" check box]]<br />
<br />
====Installation modules and blocks screens====<br />
In most cases this will be followed by a series of screens that have a continue button on the bottom. This process stops with Admin user profile settings which needs to be filled out.<br />
<br />
====Administrator user profile====<br />
[[Image:Complete install Windows 10.png|thumb|center|The administrator's users profile screen]]<br />
<br />
Fill out the required fields.<br />
*Click on "Save" to continue<br />
<br />
====Front page settings====<br />
The next screen is the Front Page settings page. There are two parts to it.<br />
The first part will ask for your Full site name and a short name for the navigation bar. There is also a place for a description. You can change these later. <br />
<br />
[[Image:Complete install Windows 11a.png|thumb|center|The Moodle sites [[Front Page]] information]]<br />
<br />
The second part on the bottom instructs Moodle if you will disable the new user self [[authentication]] through email process. The default is to disable. This can be changed later in the [[Site administration block|site administration block]].<br />
<br />
[[Image:Complete install Windows 11ba.png|thumb|center|500px|Determine if users can create their own profiles when they log onto the side via email self authentication]]<br />
<br />
*Click on "Save changes" button to go to Moodle sites home page.<br />
<br />
====Moodle on====<br />
'''Now you are ready to Moodle !'''<br />
<br />
[[Image:Complete install Windows 12.png|thumb|center|Blank Front page of your new site]]<br />
<br />
The Site Administration block is on the left, the "Turn edit on" button in the upper right corner, withe the site description block just below it.<br />
<br />
===Congratulations - Moodle has been installed===<br />
This finishes the installation of a complete package. Type <nowiki>http://localhost</nowiki> (or what ever you set for web address earlier in the setup!) in your browser and Moodle will open. <br />
<br />
Your next task will be to configure Moodle to meet your needs. Don't worry, it is easy to change any of the settings now that Moodle is up and running.<br />
*Check ''Settings > Site administration'' for further links.<br />
<br />
==More tips and cautions==<br />
*For installation on a Windows 2000 or Windows 2003 production server it is good practice to perform a manual install (see the manual installation section in [[Windows_installation|Windows Installation]]). <br />
<br />
*After installing the Windows package, you may wish to add additional contributed modules and plugins. Theset may involve more customization of configuration files.<br />
<br />
*The latest complete install package version components, may not be backwardly compatible. Always check version compatibility of each component if you intend to develop materials on a later version of Moodle than the version installed on your "main" Moodle site. In short, complete install packages are designed for first time install on a "clean" machine. <br />
<br />
== Security matters (A MUST READ!)==<br />
<br />
As mentioned before, XAMPP is not meant for production use but only for developers <br />
in a development environment. The way XAMPP is configured is to be open as possible <br />
and allowing the developer anything he/she wants. For development environments this <br />
is great but in a production environment it could be fatal. Here a list of missing security <br />
in XAMPP:<br />
<br />
The MySQL administrator (root) has no password.<br />
The MySQL daemon is accessible via network.<br />
phpMyAdmin is accessible via network.<br />
Examples are accessible via network.<br />
<br />
To fix most of the security weaknesses simply call the following URL:<br />
<br />
<nowiki>http://localhost/security/</nowiki><br />
<br />
The root password for MySQL + phpMyAdmin and also a XAMPP directory protection can be established here.<br />
<br />
Note that on the Windows installer package, some (all?) of these issues have been fixed already by default and the above link does not work.<br />
<br />
If in doubt, more info is [http://www.apachefriends.org/en/faq-xampp-windows.html here]<br />
<br />
== Apache and MySQL tweaks ==<br />
Most of the time it is not necessary to tweak Apache or MySQL after completing the complete install package. Nor is it necessary to individually start and stop them because that is what the Xampp_start, Xampp_restart and Xammp_stop files are for. <br />
<br />
<br />
=== Installing Apache and MySQL as services===<br />
(This is only for NT4 | Windows 2000 | Windows XP operating systems)<br />
<br />
\xampplite\apache\apache_installservice.bat =<br />
==> Install Apache 2 as service <br />
<br />
\xampplite\apache\apache_uninstallservice.bat =<br />
==> Uninstall Apache 2 as service <br />
<br />
\xampplite\mysql\mysql_installservice.bat =<br />
==> Install MySQL as service <br />
<br />
\xampplite\mysql\mysql_uninstallservice.bat =<br />
==> Uninstall MySQL as service <br />
<br />
==> After all Service (un)installations, please restart your system!<br />
<br />
<br />
===Apache Notes===<br />
<br />
You can use the apache_start and apache_stop bat files to start and stop apache from running. However the Xampp_start or Xampp_restart and Xampp_stop is recommended to turn on/off both Apache and MySQL.<br />
<br />
====Troubleshooting====<br />
<br />
If you find that Apache is very flaky, with the page often not loading properly or even at all (especially on localhost), try adding these lines to the end of C:\your_moodle_installer_directory\apache\conf\httpd.conf <br />
<br />
EnableSendfile Off<br />
EnableMMAP Off<br />
Win32DisableAcceptEx<br />
<br />
If You edit some .php files but browser still show old state of them, try to disable eAccelerator extension in \server\php\php.ini<br />
<br />
[eAccelerator]<br />
;extension=eaccelerator.dll<br />
<br />
===MySQL notes===<br />
Again, the recommendation to start and stop the entire webserver is to use the xampp_start or Xampp_restart and the Xampp_stop. The following maybe useful if you wish to tweak the system further. Please be careful.<br />
<br />
(1) The MySQL server can be started by double-clicking (executing) mysql_start.bat. This file can be found in the same folder you installed xampp in, most likely this will be C:\xampplite\. The exact path to this file is X:\xampplite\mysql_start.bat, where "X" indicates the letter of the drive you unpacked xampp into.This batch file starts the MySQL server in console mode. The first intialization might take a few minutes.<br />
<br />
Do not close the DOS window or you'll crash the server! To stop the server, please use mysql_shutdown.bat, which is located in the same directory.<br />
<br />
(2) To use the MySQL Daemon with "innodb" for better performance, <br />
please edit the "my" (or "my.cnf") file in the /xampplite/mysql/bin directory or for services the c:\my.cnf for windows NT/2000/XP. In that director, activate the<br />
"innodb_data_file_path=ibdata1:30M"<br />
statement. Attention, "innodb" is not recommended for 95/98/ME.<br />
<br />
:To use MySQL as Service for NT/2000/XP, simply copy the "my" / "my.cnf" file to C:\my, or C:\my.cnf. Please note that this file has to be placed in C:\ (root), other locations are not permitted. Then execute the "mysql_installservice.bat" in the mysql folder. <br />
<br />
<br />
(3) MySQL starts with standard values for the user id and the password. The preset user id is "root", the password is "" (= no password). To access MySQL via PHP with the preset values, you'll have to use the following syntax:<br />
mysql_connect("localhost","root","");<br />
If you want to set a password for MySQL access, please use of mysqladmin.<br />
To set the password "secret" for the user "root", type the following:<br />
<br />
\xampplite\mysql\bin\mysqladmin -u root password secret<br />
<br />
After changing the password you'll have to reconfigure phpMyAdmin to use the new password, otherwise it won't be able to access the databases. To do that, open the file config.inc.php in \xampplite\phpmyadmin\ and edit the following lines: <br />
<br />
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user<br />
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP authentificate<br />
<br />
So first the 'root' password is queried by the MySQL server, before phpMyAdmin may access.<br />
<br />
<br />
<br />
Have a lot of fun! Viel Spaß! Bonne Chance!<br />
<br />
==See also==<br />
<br />
*[https://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick Installation guide - Moodle 1.9 for Windows on a USB Memory Stick]<br />
*Return to [[Windows installation]]<br />
*[[Windows 1 computer many servers |Multiple web servers, on 1 computer]] similar to windows installation page, with some tips<br />
*[https://docs.moodle.org/en/Windows_installation_using_XAMPP#Troubleshooting Troubleshooting]if you are running Skype. <br />
*[[Installing_AMP]] lots of XAMPP stuff. XAMPP stands for X (cross platform), Apache, MySQL,PHP and Perl. XAMPP used in Moodle does not include Perl. MAMP stands for Mac, Apache, MySQL and PHP. <br />
*[[Installation Package for OS X]] <br />
<br />
[[es:Paquetes para Instalación Completa para Windows]]<br />
[[pl:Kompletne pakiety instalacyjne]]<br />
[[de:Vollständiges Installationspaket für Windows]]<br />
<br />
[[Category:Installation]]<br />
[[Category:Windows]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=125316Installing MSSQL for PHP2016-09-14T09:34:55Z<p>Stronk7: Added note about PHP 7 and this driver status.</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
<span id="Configuration"></span>4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<p class="note">'''Important Note 2:''' PHP 7 and following do not support the php_mssql driver [http://php.net/manual/en/intro.mssql.php anymore]. People wanting to use SQL*Server database services should switch to the [[Using_the_Microsoft_SQL_Server_Driver_for_PHP|sqlsrv drivers]] in the platforms were they are available or keep using PHP 5.6.x</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| class="table table-striped table-bordered"<br />
|-<br />
! 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<br />
|-<br />
| PHP 5.6.x (vc11-unkown architecture) || Both || 0.95 || You can find some (unverified/untested) drivers in [https://moodle.org/mod/forum/discuss.php?d=232844#p1297504 this forum post], courtesy of Josh Urbain.<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
For versions of the DLLs working with older PHP engines, you can visit [https://docs.moodle.org/30/en/Installing_MSSQL_for_PHP this page for previous Moodle releases].<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself).<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=125315Installing MSSQL for PHP2016-09-14T09:27:13Z<p>Stronk7: typo!</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
<span id="Configuration"></span>4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| class="table table-striped table-bordered"<br />
|-<br />
! 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<br />
|-<br />
| PHP 5.6.x (vc11-unkown architecture) || Both || 0.95 || You can find some (unverified/untested) drivers in [https://moodle.org/mod/forum/discuss.php?d=232844#p1297504 this forum post], courtesy of Josh Urbain.<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
For versions of the DLLs working with older PHP engines, you can visit [https://docs.moodle.org/30/en/Installing_MSSQL_for_PHP this page for previous Moodle releases].<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself).<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=125314Installing MSSQL for PHP2016-09-14T09:24:39Z<p>Stronk7: Adding a link to previous docs (3.0) were the links to older extensions are available. People really downloads them.</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
<span id="Configuration"></span>4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| class="table table-striped table-bordered"<br />
|-<br />
! 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<br />
|-<br />
| PHP 5.6.x (vc11-unkown architecture) || Both || 0.95 || You can find some (unverified/untested) drivers in [https://moodle.org/mod/forum/discuss.php?d=232844#p1297504 this forum post], courtesy of Josh Urbain.<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
For versions of the DLLs working with older PHP engines, you can visit [https://docs.moodle.org/30/en/Installing_MSSQL_for_PHP this page for previous Moodle relases].<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself).<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Talk:PostgreSQL&diff=124646Talk:PostgreSQL2016-08-04T17:18:53Z<p>Stronk7: </p>
<hr />
<div>== Client Authentication Section ==<br />
<br />
I've added a section called 'Client Authentication' to the bottom of the page, with instructions on adding an entry to 'pg_hba.conf'. I thought this was useful for people who aren't familiar with Postgres, as it will be an unfamiliar step to anyone with a background in MySQL.<br />
<br />
After six years of looking after Moodle with a MySQL setup, I had to set up my first PostgreSQL server yesterday, and this is something that stumped me for a while. If these instructions can save somebody else a bit of time, they're probably a good thing.<br />
<br />
--[[User:Alex Walker 2|Alex Walker 2]] ([[User talk:Alex Walker 2|talk]]) 18:16, 4 August 2016 (AWST)<br />
<br />
: Thanks Alex! --[[User:Eloy Lafuente (stronk7)|Eloy Lafuente (stronk7)]] ([[User talk:Eloy Lafuente (stronk7)|talk]]) 01:18, 5 August 2016 (AWST)</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=124401Installing MSSQL for PHP2016-07-25T15:46:39Z<p>Stronk7: Adding PHP 5.6 mssql candidate module link</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
<span id="Configuration"></span>4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| class="table table-striped table-bordered"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc6) || Yes || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_NOTS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| PHP 5.6.x (vc11-unkown architecture) || Both || 0.95 || You can find some (unverified/untested) drivers in [https://moodle.org/mod/forum/discuss.php?d=232844#p1297504 this forum post], courtesy of Josh Urbain.<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=AMOS&diff=122242AMOS2016-02-10T22:12:26Z<p>Stronk7: Redirected page to dev:AMOS</p>
<hr />
<div>#REDIRECT [[dev:AMOS]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=AMOS&diff=122241AMOS2016-02-10T21:30:09Z<p>Stronk7: </p>
<hr />
<div>#REDIRECT [[dev:AMOS manual]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=AMOS&diff=122240AMOS2016-02-10T21:28:28Z<p>Stronk7: </p>
<hr />
<div>#redirect [[dev:AMOS manual]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Upgrading_to_Moodle_3.0&diff=121241Upgrading to Moodle 3.02015-11-16T01:20:51Z<p>Stronk7: Just detected that this was missing and it's the schema followed by downloads links... we can change to the new one if all releases do support it.</p>
<hr />
<div>#redirect [[Upgrading]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=119765Installing MSSQL for PHP2015-09-08T00:40:25Z<p>Stronk7: /* Installation overview */</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
<span id="Configuration"></span>4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| class="table table-striped table-bordered"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc6) || Yes || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_NOTS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Talk:Course_meta_link&diff=118295Talk:Course meta link2015-04-28T17:25:44Z<p>Stronk7: </p>
<hr />
<div>Can anyone offer some explanation as to what the "External unenrol action" setting in the Course meta link plugin does? [[User:Jon Witts|Jon Witts]] ([[User talk:Jon Witts|talk]]) 03:54, 27 November 2014 (AWST)<br />
<br />
----<br />
One little (not so little) annoyance with the meta-link enrol is that here and there we use different nomenclatures to point to them (linked and meta, child and meta)... and I always end looking to the Docs or code to see which one is every one. I'd suggest to move to something like source/target or, alternatively, at very least, define clearly what is the child course and what's the meta course. Of course that applies to both Docs and Moodle UI.<br />
<br />
In other words. I've not idea about the best alternative, but can confirm that the current situation leads me to confusion every time I look (not often, surely that contributes to the confusion, be warned).<br />
<br />
Surely this is something that can wait for 3.0 or so, not critical at all.<br />
<br />
[[User:Eloy Lafuente (stronk7)|Eloy Lafuente (stronk7)]] ([[User talk:Eloy Lafuente (stronk7)|talk]]) 01:25, 29 April 2015 (AWST)</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Talk:Course_meta_link&diff=118294Talk:Course meta link2015-04-28T17:25:07Z<p>Stronk7: Confusion with current child/meta nomenclature.</p>
<hr />
<div>Can anyone offer some explanation as to what the "External unenrol action" setting in the Course meta link plugin does? [[User:Jon Witts|Jon Witts]] ([[User talk:Jon Witts|talk]]) 03:54, 27 November 2014 (AWST)<br />
<br />
One little (not so little) annoyance with the meta-link enrol is that here and there we use different nomenclatures to point to them (linked and meta, child and meta)... and I always end looking to the Docs or code to see which one is every one. I'd suggest to move to something like source/target or, alternatively, at very least, define clearly what is the child course and what's the meta course. Of course that applies to both Docs and Moodle UI.<br />
<br />
In other words. I've not idea about the best alternative, but can confirm that the current situation leads me to confusion every time I look (not often, surely that contributes to the confusion, be warned).<br />
<br />
Surely this is something that can wait for 3.0 or so, not critical at all.<br />
<br />
[[User:Eloy Lafuente (stronk7)|Eloy Lafuente (stronk7)]] ([[User talk:Eloy Lafuente (stronk7)|talk]]) 01:25, 29 April 2015 (AWST)</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=112281Installing MSSQL for PHP2014-05-05T01:44:11Z<p>Stronk7: Added new freetds builds working on Windows7 (original ones were not)</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc6) || Yes || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_NOTS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.102 || [http://download.moodle.org/download.php/dblib/php54_vc9_091102/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Git_for_Administrators&diff=110574Git for Administrators2014-03-01T10:21:53Z<p>Stronk7: fixed link to forum discussion</p>
<hr />
<div>{{Installing Moodle}}<br />
This page describes how to maintain a copy of Moodle on your production server which can easily be upgraded using Git. If you have customisations of Moodle core code, you are advised to follow the instructions in the [[Development:Quick Git start guide for Moodle development|Quick Git start guide for Moodle development]].<br />
<br />
To get the most of of Git it is worth making the effort to understand its basic concepts - see the See also section below. It can be a bit of a learning curve, especially if you are used to CVS or Subversion. <br />
<br />
== Getting hold of Git (Windows, OSX, Linux and others) ==<br />
<br />
Support for Git was, up until recently, mostly confined to Linux but builds are now available for most popular operating systems:<br />
<br />
* List of downloads from Git site - http://git-scm.com/download<br />
<br />
Once you have downloaded and installed your OS relevant git installation, the git commands in this document should work with your operating system.<br />
<br />
== Obtaining the code from Git ==<br />
<br />
The command line version of Git is discussed here. Graphical clients are little more than wrappers around the command line version, so you should be able to deduce the correct parameters quite easily. <br />
<br />
You can find the official Moodle git repository at git://git.moodle.org/moodle.git (with an official clone at git://github.com/moodle/moodle.git). To initialize your local checkout, use<br />
<pre><br />
$ git clone git://git.moodle.org/moodle.git (1)<br />
$ cd moodle<br />
$ git branch -a (2)<br />
$ git branch --track MOODLE_26_STABLE origin/MOODLE_26_STABLE (3)<br />
$ git checkout MOODLE_26_STABLE (4)<br />
</pre><br />
* The command (1) initializes the new local repository as a clone of the 'upstream' (i.e. the remote server based) moodle.git repository. The upstream repository is called 'origin' by default. It creates a new directory named ''moodle'', where it downloads all the files. This operation can take a while as it is actually getting the entire history of all Moodle versions<br />
* The command (2) lists all available branches.<br />
* Use the command (3) to create a new local branch called MOODLE_26_STABLE and set it to track the remote branch MOODLE_26_STABLE from the upstream repository.<br />
* The command (4) actually switches to the newly created local branch. <br />
<br />
Note that Git has a huge number of options for each command and it's actually possible to do the above process with a single command (left as an exercise!!).<br />
<br />
==Git from behind a firewall==<br />
<br />
Git uses a read-only protocol that may be blocked by your firewall (port 9418). If this is a problem, you can use Github's http version <nowiki>https://github.com/moodle/moodle.git</nowiki>. It's a bit slower, so use the Git protocol if you can.<br />
<br />
== Updating your installation ==<br />
<br />
The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the [http://git.moodle.org/gw?p=moodle.git;a=summary shortlog] to see if the official repository has been already updated or not.<br />
<br />
To update your code to the latest version (on the MOODLE_26_STABLE branch) '''all''' you have to do is:<br />
<pre><br />
$ cd /path/to/your/moodle/<br />
$ git pull<br />
</pre><br />
If this is a production site you should still consider the [[Upgrade]] instructions (e.g. take backups).<br />
<br />
== Installing a contributed extension from its Git repository ==<br />
<br />
This is one way to handle adding plugins from other Git repositories into your Moodle repository. Another way is to use Git Submodules. However, at the time of writing, this is one of Git's rougher features and should be regarded as an advanced option. <br />
<br />
For example, let us say we want to install the [[Certificate module]] from its Git repository into our Moodle 2.6.<br />
<pre><br />
$ cd /path/to/your/moodle/<br />
$ cd mod (1)<br />
$ git clone https://github.com/markn86/moodle-mod_certificate.git certificate (2)<br />
$ cd certificate<br />
$ git checkout -b MOODLE_26_STABLE origin/MOODLE_26_STABLE (3)<br />
$ git branch -d master (4)<br />
</pre><br />
The command (1) changes the current directory into the ''mod'' folder of your local Moodle clone. The command (2) creates a new subdirectory ''certificate'' and makes a local clone of vanilla Certificate repository. The command (3) creates a new local branch that will track the remote branch with a Certificate version for Moodle 2.6. The command (4) deletes the ''master'' that was created automatically by git-clone in (2) as we do not want it in this production checkout.<br />
<br />
Note: you should check first the compatibility of a module with your Moodle branch by asking directly to the Maintainer before cloning the repo or - if you want to guess it - by issueing the command below before running the command (3), in order to verify what is available among the branches:<br />
<pre><br />
$ git branch -a<br />
* master<br />
remotes/origin/HEAD -> origin/master<br />
remotes/origin/MOODLE_20_STABLE<br />
remotes/origin/MOODLE_21_STABLE<br />
remotes/origin/MOODLE_22_STABLE<br />
remotes/origin/MOODLE_23_STABLE<br />
remotes/origin/MOODLE_24_STABLE<br />
remotes/origin/MOODLE_25_STABLE<br />
remotes/origin/MOODLE_26_STABLE<br />
remotes/origin/master<br />
</pre><br />
This will avoid an error message when you issue the command (3) against a nonexistent branch, e.g.:<br />
<pre><br />
§ git checkout -b MOODLE_27_STABLE origin/MOODLE_27_STABLE<br />
fatal: git checkout: updating paths is incompatible with switching branches.<br />
Did you intend to checkout 'origin/MOODLE_27_STABLE' which can not be resolved as commit?<br />
</pre><br />
<br />
Now it is wise to put the new directory mod/certificate/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.<br />
<pre><br />
$ cd /path/to/your/moodle/<br />
$ echo /mod/certificate/ >> .git/info/exclude<br />
</pre><br />
To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.<br />
<pre><br />
$ cd /path/to/your/moodle/<br />
$ git pull<br />
$ cd mod/certificate<br />
$ git pull<br />
</pre><br />
Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.<br />
<br />
== See also ==<br />
<br />
; Moodle Docs<br />
* [[Git FAQ]]<br />
* [[Windows installation using Git]]<br />
* [[Git for Mac]]<br />
* [[:dev:Moodle versions]]<br />
* For some screenshots see [[User:Frank_Ralf/Git]] (still work in progress)<br />
* For fixing a Tracker Issue (MDL) / Forking Moodle / CONTRIButing code ... [[User:Sam_Hemelryk/My_Moodle_Git_workflow]]<br />
* [[Moodle_Production_Server_with_GIT|Case study Git + Moodle from Technical University Berlin]]<br />
<br />
; Moodle forum discussions<br />
* [https://moodle.org/mod/forum/discuss.php?d=255175 Github and Moodle deployment for production]<br />
* [https://moodle.org/mod/forum/discuss.php?d=213695 Got GIT installed on my site- here's how!]<br />
* [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed]<br />
* [http://moodle.org/mod/forum/discuss.php?d=165236 Best way to manage CONTRIB code with GIT]<br />
* [http://moodle.org/mod/forum/discuss.php?d=167063 Handy Git tip for tracking 3rd-party modules and plugins]<br />
* [http://moodle.org/mod/forum/discuss.php?d=167730 Moodle Git repositories]<br />
* [http://moodle.org/mod/forum/discuss.php?d=183693 Git and CVS]<br />
* [http://moodle.org/mod/forum/discuss.php?d=208904 GIT for dummies]<br />
* [http://moodle.org/mod/forum/discuss.php?d=211930 Git and upgrading misunderstanding]<br />
* [https://moodle.org/mod/forum/discuss.php?d=231046 Clear git guide for Admins (not developers)]<br />
<br />
; External resources <br />
* [http://thamblings.blogspot.com.au/2013/07/upgrading-moodle-from-git.html Deploying Moodle from git - Blog post from a production experience]<br />
* [http://www.kernel.org/pub/software/scm/git/docs/everyday.html Everyday GIT With 20 Commands Or So]<br />
* [http://gitref.org/ Git Reference]<br />
* [http://progit.org/book/ Pro Git book]<br />
* [http://eigenjoy.com/2008/05/15/git-from-the-bottom-up/ Git from the bottom up]<br />
<br />
[[ja:管理者用Git]]<br />
[[fr:Git_pour_administrateurs]]<br />
[[es:Git para Administradores]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Verify_Database_Schema&diff=108384Verify Database Schema2013-12-14T15:46:26Z<p>Stronk7: Get rid of databases forum link. [https://moodle.org/mod/forum/discuss.php?d=217775]</p>
<hr />
<div>{{Installing Moodle}}<br />
If you have been upgrading your Moodle site over several versions, it is possible (likely even) that some differences may have crept in between the database table definitions (the "schema") in your database and the version you would get creating a new empty site. This happens because of small errors or oversights in the upgrade scripts. Most of these differences are not harmful, but some may cause strange or unexpected errors. For example, if a default value has been added to a field and this was not reflected in an upgrade script code that assumes the presence of the default may fail to work as expected. <br />
<br />
The solution is after doing an upgrade (or, if your problem is that the upgrade fails, before) to compare the database schema of the "production" site to that of a newly created site (where no upgrades have been performed) using '''exactly''' the same code base. There are a number of ways of doing this, but this article outlines a simple way using the Unix command line.<br />
<br />
* Complete the upgrade<br />
* Generate the database schema from your recently upgraded site using the following command:<br />
# MySQL<br />
mysqldump --no-data -u root -p ''myproductiondb'' >production.schema<br />
# PostgreSQL<br />
pg_dump --schema-only -U postgres ''myproductiondb'' > production.schema<br />
* Copy the code of your production database to a new (web accessible) location (this is important, it *must* be the same version)<br />
* Create a new, empty database and moodledata area for the new site as per the [[Installation]] instructions<br />
* Edit the config.php file to point at the new database and locations, or delete it and use the install script<br />
* Run the install script to generate the (if applicable) config.php file and the database (admin and site values are not important)<br />
* Generate the database schema from your new site using the following command:<br />
# MySQL<br />
mysqldump --no-data -u root -p ''mycleandb'' >clean.schema<br />
# PostgreSQL<br />
pg_dump --schema-only -U postgres ''mycleandb'' > clean.schema<br />
* Run the following command to detect the differences<br />
diff -u production.schema clean.schema >db.diff<br />
<br />
You can now look at ''db.diff'' with your favorite editor to see the differences.<br />
<br />
'''NOTE:''' The above obviously applies to MySQL databases. Other databases are likely to have a similar function to dump only the schema. For example PostgreSQL has the '''pg_dump''' command. The remainder of the discussion still applies. <br />
<br />
==Interpreting the diff file==<br />
<br />
Firstly here's a (real) example:<br />
<br />
--<br />
-- Table structure for table `mdl_backup_config`<br />
@@ -129,11 +93,11 @@<br />
DROP TABLE IF EXISTS `mdl_backup_config`;<br />
CREATE TABLE `mdl_backup_config` (<br />
- `id` int(10) unsigned NOT NULL auto_increment,<br />
+ `id` bigint(10) unsigned NOT NULL auto_increment,<br />
`name` varchar(255) NOT NULL default '',<br />
`value` varchar(255) NOT NULL default '',<br />
PRIMARY KEY (`id`),<br />
- UNIQUE KEY `name` (`name`)<br />
+ UNIQUE KEY `mdl_backconf_nam_uix` (`name`)<br />
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='To store backup configuration variables';<br />
<br />
The file may have lots of blocks of changes. The - lines show lines to be taken out and the + lines the ones to replace them (from the production to the clean). So here, the int has been replaced with a bigint and the key name changed. Both of these, technically, should have been changed at some point by upgrade scripts but have been missed. In this case they are unlikely to affect the operation of Moodle. <br />
<br />
===Too many changes to track manually?===<br />
<br />
You can also use database management programs to synchronize old and new Moodle databases.<br />
<br />
For example [http://wb.mysql.com/ MySQL Workbench] for MySQL databases.<br />
<br />
This is very useful, if you have a lot of changes.<br />
<br />
If you can work a Unix/Linux command line the Python script [http://schemasync.org/ Schema Sync] provides a quick and simple way to generate all the commands to update your database.<br />
<br />
==Should I worry?==<br />
<br />
Changes in field types (as long as they are compatible) and key name changes seem to be the common issues but '''should''' not cause problems. Things to look out for would be along the lines of missing fields and changes to default values.<br />
<br />
If you are about to upgrade to Moodle 2.0 you should be more concerned. In order for the upgrade to proceed smoothly it is a very good idea to correct these problems.<br />
<br />
== See also ==<br />
<br />
* The missing indexes report in ''SiteAdmin->Misc->XMLDB editor->Check Indexes''<br />
<br />
[[de:Datenbank-Schema prüfen]]<br />
[[fr:Vérification du schéma de la base de données]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=PostgreSQL&diff=108383PostgreSQL2013-12-14T15:43:12Z<p>Stronk7: Get rid of databases forum link. [https://moodle.org/mod/forum/discuss.php?d=217775]</p>
<hr />
<div>{{Installing Moodle}}<br />
PostgreSQL is one of the two databases that is fully supported by Moodle. A database is a required component of any Moodle installation.<br />
<br />
== Creating Moodle Database ==<br />
<br />
These instructions assume that the database server and web server are on the same machine. If that is not the case you have some more work to do. See the PostgreSQL documentation for further details. <br />
<br />
* Log into the PostgreSQL command line client. The exact form depends on how your PostgreSQL is configured but will be something like<br />
<br />
$ psql -U postgres<br />
Password for user postgres:<br />
<br />
Enter the password for your 'postgres' user set during installation. After some preamble you should see the prompt ''postgres=#''.<br />
<br />
* Create the user for the Moodle database and assign a password:<br />
<br />
postgres=# CREATE USER moodleuser WITH PASSWORD 'yourpassword';<br />
<br />
Provide a suitably strong password. Please note that the actual authentication method depends on your PostgreSQL server's pg_hba.conf file. Some authentication methods (like ident) do not require the password.<br />
<br />
* Create the database:<br />
<br />
postgres=# CREATE DATABASE moodle WITH OWNER moodleuser;<br />
<br />
== Character set and collation ==<br />
<br />
If the PostgreSQL server's default collation does not suit your needs, you can provide explicit LC_CTYPE (character classification) and LC_COLLATE (string sort order) setting for your Moodle database. The following example creates new database called 'moodle' optimised for a Czech Moodle site:<br />
<br />
postgres=# CREATE DATABASE moodle WITH OWNER moodleuser ENCODING 'UTF8' LC_COLLATE='cs_CZ.utf8' LC_CTYPE='cs_CZ.utf8' TEMPLATE=template0;<br />
<br />
For more details refer to [http://www.postgresql.org/docs/9.1/static/multibyte.html Character Set Support] chapter in PostgreSQL manual.<br />
<br />
To make sure the database was created correctly, use the ''\l'' at the psql console or execute ''psql -l'' shell command. You should get something like<br />
<br />
postgres=# \l<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges <br />
-----------+------------+----------+-------------+-------------+-----------------------<br />
moodle | moodleuser | UTF8 | cs_CZ.utf8 | cs_CZ.utf8 | <br />
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | <br />
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres<br />
: postgres=CTc/postgres<br />
<br />
== See also ==<br />
<br />
* [http://www.postgresql.org PostgreSQL home page]<br />
* [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server Tuning Your PostgreSQL Server]<br />
* [[Arguments in favour of PostgreSQL]]<br />
* [http://en.wikipedia.org/wiki/Postgres Wikipedia article on PostgerSQL]<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=49195 Upgrading to 1.6 and may need to switch to PostgreSQL] forum discussion<br />
<br />
[[Category:SQL databases]]<br />
<br />
[[es:PostgreSQL]]<br />
[[ja:PostgreSQL]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=MySQL&diff=108382MySQL2013-12-14T15:42:46Z<p>Stronk7: Get rid of databases forum link. [https://moodle.org/mod/forum/discuss.php?d=217775]</p>
<hr />
<div>{{Installing Moodle}}<br />
MySQL is one of the supported databases that underpins a Moodle installation. <br />
<br />
== Installing MySQL ==<br />
<br />
* If you are running Linux your preference should be to install using your distributions package manager. This ensures you will get any available updates. <br />
* There are installers available for most popular operating systems at http://www.mysql.com/downloads/mysql/.<br />
* It is possible and reasonably straightforward to build mysql from source but it is not recommended (the pre-built binaries are supposedly better optimised).<br />
* Make sure you set a password for the 'root' user (see http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html).<br />
* Consider installing and configuring my.cnf (the MySQL settings file) to suit your needs. The default configuration is usually very conservative in respect of memory usage versus performance.<br />
<br />
== Creating Moodle database ==<br />
<br />
These are the steps to create an empty Moodle database. Substitute your own database name, user name and password as appropriate.<br />
<br />
The instructions assume that the web server and MySQL server are on the same machine. In this case the 'dbhost' is 'localhost'. If they are on different machines substitute the name of the web server for 'localhost' in the following instructions and the 'dbhost' setting will be the name of the database server. <br />
<br />
=== Command line === <br />
<br />
* To create a database using the 'mysql' command line client, first log into MySQL<br />
<pre><br />
$ mysql -u root -p<br />
Enter password: <br />
</pre><br />
(Enter the password you previously set - or been given - for the MySQL 'root' user). After some pre-amble this should take you to the ''mysql>'' prompt.<br />
* Create a new database (called 'moodle' - substitute your own name if required). We recommend you use '''utf8_unicode_ci''' for collation.<br />
<pre><br />
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;<br />
</pre><br />
* Add a user/password with the minimum needed permissions:<br />
<pre><br />
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'yourpassword';<br />
</pre><br />
...which creates a user called 'moodleuser' with a password 'yourpassword'. Make sure you invent a strong password and resist the temptation to 'GRANT ALL'.<br />
<br />
=== phpMyAdmin ===<br />
<br />
[http://www.phpmyadmin.net/ phpMyAdmin] is a web based administration tool for MySQL. If this is available you can use it to create a new database. Make sure that you select 'UTF8' as the default character set.<br />
<br />
== See also ==<br />
<br />
* [[MariaDB]]<br />
* [http://www.mysql.com/ The MySQL homepage]<br />
* [http://en.wikipedia.org/wiki/MySQL Wikipedia article about ''MySQL'']<br />
* [http://forums.mysql.com/read.php?24,92131,92131 List of articles on MySQL performance tuning]<br />
<br />
[[Category:SQL databases]]<br />
<br />
[[ja:MySQL]]<br />
[[de:MySQL]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108376Installing MSSQL for PHP2013-12-13T19:32:25Z<p>Stronk7: 93, is 91.93 (in Matt Rusiniak words)</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc6) || Yes || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.93 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108375Installing MSSQL for PHP2013-12-13T19:02:05Z<p>Stronk7: Adding links to download.moodle.org php53_vc6</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc6) || Yes || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches (unconfirmed) || [http://download.moodle.org/download.php/dblib/php53_vc6/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.92 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.92 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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]] and Matt Rusiniak 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108374Installing MSSQL for PHP2013-12-13T18:51:11Z<p>Stronk7: Adding links to download.moodle.org php55_vc11_x64</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x64) || Yes || 0.91.92 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.92 || [http://download.moodle.org/download.php/dblib/php55_vc11_x64/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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 and Matt Rusiniak for providing the PHP 5.5 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108373Installing MSSQL for PHP2013-12-13T18:40:45Z<p>Stronk7: /* Using FreeTDS on Windows */</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108372Installing MSSQL for PHP2013-12-13T18:40:01Z<p>Stronk7: Adding links to download.moodle.org php55_vc11_x86</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | PHP 5.5.x (vc11-x86) || Yes || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.91.89 || [http://download.moodle.org/download.php/dblib/php55_vc11_x86/DBLIB_TS.zip Download!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108371Installing MSSQL for PHP2013-12-13T18:21:21Z<p>Stronk7: Adding links to download.moodle.org php53_vc9</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53_vc9/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108370Installing MSSQL for PHP2013-12-13T18:20:14Z<p>Stronk7: Adding links to download.moodle.org php4_vc9</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.4.x (vc9) || Yes || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_ts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_TS.zip 2 (ftp)] [http://www.sendspace.com/file/vtger3 3]<br />
|-<br />
| No || 0.82 + 20110906 patches || [http://download.moodle.org/download.php/dblib/php54_vc9/DBLIB_TS.zip Download!] Mirrors: [http://inethub.olvi.net.ua/ftp/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/dblib_nts.zip 1] [ftp://inethub.olvi.net.ua/pub/soft/programming/php/ms%20sql%20driver%20for%20%20php%205.4.10/DBLIB_NTS.zip 2 (ftp)] [http://www.sendspace.com/file/nkg2j4 3]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&diff=108368Using the Microsoft SQL Server Driver for PHP2013-12-13T16:58:40Z<p>Stronk7: /* See Also */</p>
<hr />
<div>{{Installing Moodle}}<br />
== Using the SQL Server Driver for PHP from Microsoft ==<br />
<br />
== Introduction ==<br />
This short manual is for running Moodle 2.0 (and upwards) using the Microsoft SQL Server (MSSQL) RDBMS. The steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
First of all, the minimum required version of MSSQL has been stabilized to MSSQL 2005 (v.9).<br />
<br />
== Installation overview ==<br />
1. Install Microsoft SQL Server including SQL Server Management Studio. ([http://www.microsoft.com/sql/editions/express/default.mspx A free version, SQL Server Express Edition] is available for testing.)<br />
:Make sure to choose mixed authentication (Windows and local accounts) to keep things simpler later. Define the "sa" account password when requested (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Configure Windows for MSSQL.<br />
:By default, MSSQL listens to port 1433 for incoming TCP/IP connections and this port needs to be opened in the firewall. This is explicitly configured in the firewall installed (either Windows Firewall in the Control Panel or the configuration interface for other firewalls). If the port was changed when MSSQL was installed, then specify the correct port number to open in the firewall.<br />
:Confirm the TCP/IP protocol is enabled in: '''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Create and configure a new database.<br />
:Open "SQL Server Management Studio" and create a new empty database.<br />
*Execute the following command to enable Row Versioning:<br />
<br />
<code><br />
USE MASTER<br />
GO<br />
ALTER DATABASE &lt;your-database-name&gt; SET READ_COMMITTED_SNAPSHOT ON<br />
GO<br />
</code><br />
<br />
4. Install PHP and a web server.<br />
*PHP can be downloaded from [http://www.php.net/downloads.php www.php.net]<br />
*If IIS is used as the web server, IIS 7.0 or later is recommended with [http://www.iis.net/download FastCGI and WinCache]. <br />
<br />
5. Install the SQL Server Driver for PHP.<br />
:On the web server, install [http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=20098 SQL Server Driver for PHP] including all the pre-requisites listed on the download page. Note: it is critical to install the SQL Server Native Access Client version documented on the download page of the SQL Server Driver for PHP.<br />
:Configure PHP to use the appropriate SQLSRV driver. In php.ini, set the following:<br />
<br />
For PHP 5.2.4 (or later)<br />
<br />
<code><br />
[PHP_SQLSRV]<br />
extension=php_sqlsrv_52_nts_vc9.dll<br />
</code><br />
<br />
For PHP 5.3.2 (or later)<br />
<br />
<code><br />
[PHP_SQLSRV]<br />
extension=php_sqlsrv_53_nts_vc9.dll<br />
</code><br />
<br />
The Microsoft documentation for the SQL Server Driver for PHP is available at: http://msdn.microsoft.com/en-us/library/ee229548(v=SQL.10).aspx <br />
<br />
6. Install and configure Moodle.<br />
:Continue with the [[Installing Moodle|standard Moodle installation]].<br />
<br />
7. The Moodle '''config.php''' should include lines like these:<br />
<code php><br />
$CFG->dbtype = 'sqlsrv'; // Required<br />
$CFG->dbhost = 'localhost'; // Assuming that MSSQL is on the same server, otherwise <br />
// use the actual name or IP address of your database server<br />
$CFG->dbname = 'moodle'; // The name of the newly created Moodle database<br />
$CFG->dbuser = 'yourusername'; // Usually the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = true;<br />
$CFG->prefix = 'mdl_'; // The prefix can be changed per individual preferences, <br />
// but NEVER leave this blank!<br />
</code><br />
<br />
:If the config.php file doesn't exist, it will be generated as normal from the Moodle installer. Alternatively, use the config-dist.php file that comes with the Moodle package to create a custom config.php file.<br />
<br />
8. Restart or start your web server.<br />
:If Moodle still cannot communicate with the database server, turn '''display_startup_errors''' to "On" in the /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.<br />
<br />
9. Test the database connection.<br />
:Try this PHP script, just add a text file called test.php from the example below and change ('localhost', 'db_user', 'db_password') to align with the config.php settings, and load from local host (http://localhost/test.php).<br />
<br />
<code php><br />
<?php<br />
$link = sqlsrv_connect($this->dbhost, array('UID' => 'db_user', 'PWD' => 'db_password'));<br />
if($link === FALSE) {<br />
echo 'Could not connect';<br />
die('Could not connect: ' . sqlsrv_errors(SQLSRV_ERR_ALL));<br />
}<br />
echo 'Successful connection';<br />
sqlsrv_close($link);<br />
?><br />
</code><br />
<br />
10. Complete the rest of the Moodle installation as usual.<br />
<br />
== See Also ==<br />
* [[Errors FAQ]]<br />
* [[Installing MSSQL for PHP]], about how to install Moodle on SQL*Server using the FreeTDS drivers.<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* Microsoft SQL Server Driver for PHP solves major Moodle performance problems. See: [http://moodle.org/mod/forum/discuss.php?d=183987 Hardware and Performance Forum]<br />
<br />
[[Category:XMLDB]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108367Installing MSSQL for PHP2013-12-13T16:56:27Z<p>Stronk7: /* Microsoft Drivers for SQL Server for PHP */</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
To know more about how to run Moodle with these drivers go to [[Using the Microsoft SQL Server Driver for PHP]].<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | 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]<br />
|-<br />
| 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]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108366Installing MSSQL for PHP2013-12-13T16:54:51Z<p>Stronk7: Moving link to sqlsrv own section so people interested on it avoids reading all the freetds stuff</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | 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]<br />
|-<br />
| 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]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=108365Installing MSSQL for PHP2013-12-13T16:37:55Z<p>Stronk7: Undo revision 107709 by Tsala (talk) - FreeTDS for windows, the binaries and the building instructions have interest enough to keep them here. Commented @ HQ chat and with Helen.</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9).<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = True (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = True (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:*Is Read Committed transaction ON = True (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** In older versions 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | 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]<br />
|-<br />
| 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]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
Note2: Please note that updating php tends to remove the freetds configurations. You might need to reconfigure freetds after an upgrade<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See also ==<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* [[Using the Microsoft SQL Server Driver for PHP]]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=106185Installing MSSQL for PHP2013-07-26T12:08:14Z<p>Stronk7: Taking rid of warning caused by MDL-37734</p>
<hr />
<div>{{Installing Moodle}}== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it '''might work with MSSQL 2000 (v.8) or newer'''. All the development process has been performed using MSSQL 2005 and there could be some '''unknown problems''' with previous releases.<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
Configure these settings in your created (and still empty) database:<br />
:*Use a case sensitive collation, such as Latin1_General_CS_AS.<br />
:*ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:*Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:* (Moodle 2.x only) Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)<br />
:** 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 "Object Explorer" (right-click > Disconnect), then create a "New Query" and run the ALTER command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx for details.<br />
:** If your DB name starts with a number, you may need to put quotes around the DB name in the query.<br />
<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Microsoft Drivers for SQL Server for PHP ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
For Windows servers with [[Apache]] see http://www.microsoft.com/en-us/download/details.aspx?id=20098.<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | 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]<br />
|-<br />
| 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]<br />
|-<br />
| rowspan="2" | 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!]<br />
|-<br />
| 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!]<br />
|-<br />
| colspan="4" | 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!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See Also ==<br />
* 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]<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* [[Installing Postgres for PHP]]<br />
* [[Using the Microsoft SQL Server Driver for PHP]]<br />
* [[Installing Oracle for PHP]]<br />
<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_Oracle_for_PHP&diff=96902Installing Oracle for PHP2012-04-12T14:21:04Z<p>Stronk7: clarified the statement_cache_size setting a bit, only needed for testing</p>
<hr />
<div>* http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html<br />
* http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (with attached html document)<br />
* http://es.php.net/oci8<br />
<br />
<br />
== Broken versions of OCI8 driver ==<br />
<br />
PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:<br />
<br />
* Upgrade to PHP v5.2.5 or later<br />
* Downgrade to PHP v5.2.1 (reported to work)<br />
* Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)<br />
* If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8<br />
<br />
More information at<br />
* http://bugs.php.net/bug.php?id=42496 -- tracking the PHP OCI8 bug<br />
* http://tracker.moodle.org/browse/MDL-11429 -- diagnostics on the Moodle side<br />
<br />
== Installing Moodle on Windows with Oracle Express Edition ==<br />
<br />
=== Introduction ===<br />
This section explains how to install Moodle with Oracle Express Edition on Windows. I'm using it for '''debugging''' purpose. It's definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.<br />
<br />
=== Install Oracle ===<br />
# Download Oracle Express Edition on [http://www.oracle.com/technology/products/database/xe/index.html Oracle web site].<br />
# You will also need the Instant client [http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html from here] (free account sign up needed). Copy everything from the unzipped folder into apache/bin.<br />
# Install both.<br /><br />
# Access to the oracle console at http://127.0.0.1:8080/apex (Login=SYS Password=the_one_you_entered_during_the_installation).<br />
# Create a new user and give it all rights (including DBA).<br />
# Go to the SQL Commands page and grant your new user the dmbs_lock permission...<code sql><br />
grant execute on dbms_lock to XXXXX;<br />
</code>...where XXXXX is the username of your new user.<br />
# Log out and log in as the new user.<br />
# Run the script found in the Moodle codebase at /lib/dml/oci_native_moodle_package.sql. If you can not run this script directly, you can run its parts (separated by slashes) independently via the SQL Commands page.<br />
<br />
Note: Oracle Express Edition 10g is limited at one database called 'XE'.<br />
<br />
=== Set up your Oracle extension ===<br />
<br />
This document does not explain how to setup apache/php for Oracle. You can have more information on [http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html Oracle Documentation].<br />
<br />
Edit your phi.ini file, uncomment (remove the leading semicolon) the php_oci8 extension. In a WAMP setup, this is listed as...<br />
<br />
<code><br />
extension=php_oci8.dll<br />
</code><br />
<br />
Also, if you are going to use the installation for development/testing purposes, uncomment the following line and set the value to zero. It's not needed for normal operations (it causes a BIG slowdown of the system!).<br />
<br />
<code><br />
oci8.statement_cache_size = 0<br />
</code><br />
<br />
You may also need to uncomment php_oracle, php_pdo_oci, php_pdo_oci8 in some set-ups.<br />
<br />
=== Install Moodle ===<br />
On the database setup page:<br /><br />
Driver: Oracle oci8 (in the config file it should read "oci8po" for a 1.9.x install and "oci" for a 2.0.x install)<br /><br />
Host: empty the field<br /><br />
Database: //localhost:1521/XE<br /><br />
User: the user that you created<br /><br />
Password: the password you gave to the user<br /><br />
<br />
=== Configure Apache ===<br />
<br />
If you're running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables. To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:<br /><br />
<br /><br />
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8<br /><br />
NLS_LANG=AMERICAN_AMERICA.AL32UTF8<br /><br />
LANG=en_US.UTF-8<br /><br />
LC_ALL=en_US.UTF-8<br /><br />
LC_COLLATE=en_US.UTF-8<br /><br />
LC_CTYPE=en_US.UTF-8<br /><br />
LC_MESSAGES=en_US.UTF-8<br /><br />
LC_MONETARY=en_US.UTF-8<br /><br />
LC_NUMERIC=en_US.UTF-8<br /><br />
LC_TIME=en_US.UTF-8<br /><br />
NLS_NUMERIC_CHARACTERS='.,'<br /><br />
<br />
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH NLS_NUMERIC_CHARACTERS<br /><br />
<br /><br />
Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too. <br /><br />
<br /><br />
<br />
== Related links ==<br />
* [http://lewiscarr.co.uk/node/4 Installing ORACLE drivers with PHP]<br />
*[[Installing MSSQL for PHP]]<br />
*[[PHP]]<br />
*[http://moodle.org/mod/forum/discuss.php?d=134729#p588963 Can i install Moodle with Oracle database]<br />
*[http://moodle.org/mod/forum/discuss.php?d=65488 Who uses Oracle]<br />
*[https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Solaris_10_with_Oracle_10 Step by step Install Guide for Solaris 10 with Oracle 10]<br />
*[http://learningischange.com/2009/05/29/install-moodle-on-an-oracle-database-in-25-minutes-or-less/ Install Moodle on an Oracle Database (in 25 minutes or less)]. The related Using Moodle forum discussion is [http://moodle.org/mod/forum/discuss.php?d=124629 here].<br />
*[http://www.mguhlin.org/2009/05/moodle-on-oracle-database.html Moodle on Oracle Database] discussion on Miguel Guhlin's blog <br />
<br />
[[Category:Installation]]<br />
[[Category:Developer]]<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=94639Installing MSSQL for PHP2011-12-21T16:00:45Z<p>Stronk7: /* Installation overview */</p>
<hr />
<div>== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it '''might work with MSSQL 2000 (v.8) or newer'''. All the development process has been performed using MSSQL 2005 and there could be some '''unknown problems''' with previous releases.<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
<br />
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:* Moodle 2.x only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON) - To set READ_COMMITTED_SNAPSHOT ON (or OFF), there must be no active connections to the database except for the connection executing the ALTER DATABASE command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Using the SQL Server 2005 Driver for PHP from Microsoft on Windows ==<br />
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 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.<br />
<br />
This Microsoft driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.<br />
<br />
This driver is only supported in Moodle 2.0 and up. You should use [https://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows FreeTDS] if you are installing an older version of Moodle.<br />
<br />
See MDL-16497 and MDL-15093 for more background information.<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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 Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql_n'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*make sure the SQL Server Browser service is running SQL Server 2005 Network Configuration -> SQL Server Services<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See Also ==<br />
* 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]<br />
* [[Installing Moodle]]<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* [[Beginning Administration FAQ]]<br />
* [[Installing Postgres for PHP]]<br />
* [[Using the Microsoft SQL Server Driver for PHP]]<br />
* [[Installing Oracle for PHP]]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Installation]]<br />
[[Category:Developer]]<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=You_Might_Be_a_Moodler&diff=91232You Might Be a Moodler2011-10-05T11:06:45Z<p>Stronk7: hehehe, happened here!</p>
<hr />
<div>In the spirit of Jeff Foxworthy's ''You Might be a Redneck'' - http://www.jefffoxworthy.com/comedy/jod/index.shtml <br />
<br />
*If you have ever turned on a football game and and the orange uniforms of one team caused you to leap up from the sofa and check out moodle.org, you might be a Moodler.<br />
<br />
*If you type "moodle.org" in your browser when you intend to type "google.com."<br />
<br />
*If you look up recipes in moodle.org.<br />
<br />
*If you look up recipes in moodle.org... and [http://moodle.org/mod/forum/discuss.php?d=5395&parent=30227 find them]!<br />
<br />
*If you can spell '''Dougiamas''' without having to look it up.<br />
<br />
*If you can ''pronounce'' '''Dougiamas''' without having to look it up.<br />
<br />
*If you check the Moodle forums at 8:30 on a Saturday night.<br />
<br />
*If you find yourself heading to the bugtracker when the dishwasher is broken.<br />
<br />
*If you start seeing double square brackets around words you don't know the translation of.<br />
<br />
*If your neighbours wonder why you named your cats Helen and Howard.<br />
<br />
*Your spouse wants you to take up golf again because they hate being a 'moodle widow(er)' more.<br />
<br />
*You describe the color of something as "Moodle" orange.<br />
<br />
*If you find yourself logging in to moodle.org during your summer holiday in Italy instead of enjoying the beautiful view or going to the beach. (Hi from Italy, Sigi)<br />
<br />
*If you come all the way from Germany to the US during your summer holiday and in addition to visiting lots of places you must absolutely go to a small town in South Carolina to find out about the latest Moodle tricks<br />
<br />
*You try to figure out how to grade e-mails from your friends without a drop down box<br />
<br />
*You find moodle.org is down for some reason and the first thing you want to do is post on moodle.org about it.<br />
<br />
*Every verb you use is 'to moodle'.<br />
<br />
*You go into a Chinese restaurant and ask for a side order of Moodles with your Egg Foo Young.<br />
<br />
*You talk about Moodle so much that your non-Moodling, non-native English speaking husband asks if the noodles on the plate in front of him are moodles and when you ask him if that is what he meant to say he replies, "Yes, aren't they moodles?" (based on a true story)<br />
<br />
*You know that the course id for '''Using Moodle''' is 5.<br />
<br />
*And even if you drive a car, you always drive it in '''5'''th gear.<br />
<br />
*You throw away all but the orange M&amp;M's.<br />
<br />
*You eat all but the orange M&amp;M's (and keep it for good ''feng shui'' in your desktop).<br />
<br />
*You try to convince your wife and kids that there is a Disney Park in Perth.<br />
<br />
*The homepage of your computer is http://www.moodle.org.<br />
<br />
*The homepage of every computer you have ever laid hands on is http://www.moodle.org.<br />
<br />
*You only recently discovered that typing an address in your browser takes you to a page outside Moodle.org<br />
<br />
*You sometimes refer to your third child as '''1.3'''<br />
<br />
*Your default response to a rerun on TV is to fire up the laptop and check out moodle.org.<br />
<br />
*If you put little labels on your TV's remote control that say... view.php?id=1, view.php?id=2, etc ...<br />
<br />
*You have five browser windows open right now, four of which are Moodle sites.<br />
<br />
*Reading the moodle.org forums is part of the morning routine: coffee, newspaper, wake up the children. . .<br />
<br />
*You find yourself adding items to a list that only the Moodle clique will understand.<br />
<br />
*You tell people to "Keep Moodling" and that they have been "Moodlised"<br />
<br />
*If instead of saying ''Have a good day'' you begin greeting folks by saying ''Happy Moodling!'' and even worse when you actually believe that the two statements mean the same thing. {Based on a true story}<br />
<br />
*If normal words start being morphed into ''Moodle-isms''. For example, when someone asks ''How are you?'' you begin to reply with words like Moodle-rrific and Moodle-tastic. Subsequently, you get confused when someone gives you a quizzical look because they do not understand what have just said. {Based on a true story}<br />
<br />
*If your students start showing up to the Friday night football games wanting to know when the Moodle chant is going to begin and students begin painting ''MOODLE'' on their chests! {Based on a true story}<br />
<br />
*You get custom plates for your new car... [http://moodle.org/mod/forum/discuss.php?d=54899 Moodle Plate]<br />
<br />
*You get a quote on a custom paint job for your new car [http://classroomrevolution.com/jeff/moodleorange.jpg Moodle Orange Car]<br />
<br />
* You are looking forward to Christmas vacation so that you will have time to upgrade Moodle!<br />
<br />
* You read something interesting and your first thought is, "I have to post that at moodle.org."<br />
<br />
* You forget that the comment you just ignored from a co-worker won't be retrievable later in a Recent Activities block.<br />
<br />
* When in the supermarket, you prefer to buy orange capsicums (peppers) rather than any other colour.<br />
<br />
* If you go to http://moodle.org instead of http://google.com and try some (global) searches there, only realizing after some attempts that you are looking within Moodleland only. {Based on a true story}</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_Oracle_for_PHP&diff=89962Installing Oracle for PHP2011-09-20T08:25:46Z<p>Stronk7: </p>
<hr />
<div>* http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html<br />
* http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (with attached html document)<br />
* http://es.php.net/oci8<br />
<br />
----<br />
<br />
'''Important Note:''' Don't forget to enable this variable in your php.ini (or .htaccess) file:<br />
<br />
(else, all your data will be escaped following MySQL rules, that are incorrect for Oracle)<br />
<br />
magic_quotes_sybase = On<br />
<br />
<br />
== Broken versions of OCI8 driver ==<br />
<br />
PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:<br />
<br />
* Upgrade to PHP v5.2.5 or later<br />
* Downgrade to PHP v5.2.1 (reported to work)<br />
* Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)<br />
* If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8<br />
<br />
More information at<br />
* http://bugs.php.net/bug.php?id=42496 -- tracking the PHP OCI8 bug<br />
* http://tracker.moodle.org/browse/MDL-11429 -- diagnostics on the Moodle side<br />
<br />
== Installing Moodle on Windows with Oracle Express Edition ==<br />
<br />
=== Introduction ===<br />
This section explains how to install Moodle with Oracle Express Edition on Windows. I'm using it for '''debugging''' purpose. It's definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.<br />
<br />
=== Install Oracle ===<br />
Download Oracle Express Edition on [http://www.oracle.com/technology/products/database/xe/index.html Oracle web site].<br /><br />
You will also need the Instant client [http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html from here] (free account sign up needed). Copy everything from the unzipped folder into apache/bin. <br /><br />
Install both.<br /><br />
Access to the oracle console (http://127.0.0.1:8080/apex). Login: SYS Password: the_one_you_entered_during_the_installation<br /><br />
Create a new user and give it all rights (including DBA).<br /><br />
Note: Oracle Express Edition 10g is limited at one database called 'XE'.<br />
<br />
=== Set up your oracle extension ===<br />
This document does not explain how to setup apache/php for Oracle. You can have more information on [http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html Oracle Documentation]. On my own machine I used my WAMP installation ([http://www.en.wampserver.com/ Wampserver 2.0]) which allowed me to activate all oracle extensions in few clicks (php_oci8, php_oracle, php_pdo_oci, php_pdo_oci8).<br />
<br />
=== Install Moodle ===<br />
On the database setup page:<br /><br />
Driver: Oracle oci8 (in the config file it should read "oci8po" for a 1.9.x install and "oci" for a 2.0.x install)<br /><br />
Host: empty the field<br /><br />
Database: //localhost:1521/XE<br /><br />
User: the user that you created<br /><br />
Password: the password you gave to the user<br /><br />
<br />
=== Configure Apache ===<br />
If you're running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables. To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:<br /><br />
<br /><br />
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8<br /><br />
NLS_LANG=AMERICAN_AMERICA.AL32UTF8<br /><br />
LANG=en_US.UTF-8<br /><br />
LC_ALL=en_US.UTF-8<br /><br />
LC_COLLATE=en_US.UTF-8<br /><br />
LC_CTYPE=en_US.UTF-8<br /><br />
LC_MESSAGES=en_US.UTF-8<br /><br />
LC_MONETARY=en_US.UTF-8<br /><br />
LC_NUMERIC=en_US.UTF-8<br /><br />
LC_TIME=en_US.UTF-8<br /><br />
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH<br /><br />
<br /><br />
Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too. <br /><br />
<br /><br />
<br />
== Related links ==<br />
* [http://lewiscarr.co.uk/node/4 Installing ORACLE drivers with PHP]<br />
*[[Installing MSSQL for PHP]]<br />
*[[PHP]]<br />
*[http://moodle.org/mod/forum/discuss.php?d=134729#p588963 Can i install Moodle with Oracle database]<br />
*[http://moodle.org/mod/forum/discuss.php?d=65488 Who uses Oracle]<br />
*[https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Solaris_10_with_Oracle_10 Step by step Install Guide for Solaris 10 with Oracle 10]<br />
*[http://learningischange.com/2009/05/29/install-moodle-on-an-oracle-database-in-25-minutes-or-less/ Install Moodle on an Oracle Database (in 25 minutes or less)]. The related Using Moodle forum discussion is [http://moodle.org/mod/forum/discuss.php?d=124629 here].<br />
*[http://www.mguhlin.org/2009/05/moodle-on-oracle-database.html Moodle on Oracle Database] discussion on Miguel Guhlin's blog <br />
<br />
[[Category:Installation]]<br />
[[Category:Developer]]<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7https://docs.moodle.org/38/en/index.php?title=Installing_MSSQL_for_PHP&diff=89961Installing MSSQL for PHP2011-09-20T08:25:29Z<p>Stronk7: </p>
<hr />
<div>== Introduction ==<br />
<br />
This short manual is suitable if you are trying to run Moodle using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. <br />
<br />
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it '''might work with MSSQL 2000 (v.8) or newer'''. All the development process has been performed using MSSQL 2005 and there could be some '''unknown problems''' with previous releases.<br />
<br />
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]]).<br />
<br />
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a '''mssql extension alternative''' to save us from the problems related above. See the sections below for details about the various options.<br />
<br />
== Installation overview ==<br />
<br />
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.)<br />
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later. You'll be asked to define the "sa" account password (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).<br />
:You might need to explicitly allow this in your Windows firewall (see the Control Panel). You may also need to edit options in the :'''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Open the "SQL Server Management Studio" and create a new empty database. If you are using the "sa" account then you don't need to do anything else here.<br />
<br />
4. Configure these settings in your created (and still empty) database:<br />
<br />
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)<br />
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)<br />
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON) - To set READ_COMMITTED_SNAPSHOT ON (or OFF), there must be no active connections to the database except for the connection executing the ALTER DATABASE command. See http://msdn.microsoft.com/en-us/library/bb522682.aspx<br />
<br />
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.<br />
<br />
6. Choose one of the following specific sections for your server to install the '''mssql extension alternative''' installed and running properly on your PHP box.<br />
<br />
7. Set the following settings in your php.ini file<br />
:* mssql.textlimit = 20971520<br />
:* mssql.textsize = 20971520<br />
<br />
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].<br />
<br />
== Using the SQL Server 2005 Driver for PHP from Microsoft on Windows ==<br />
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 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.<br />
<br />
This Microsoft driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.<br />
<br />
This driver is only supported in Moodle 2.0 and up. You should use [https://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows FreeTDS] if you are installing an older version of Moodle.<br />
<br />
See MDL-16497 and MDL-15093 for more background information.<br />
<br />
== Using FreeTDS on Windows ==<br />
<br />
<p class="note">'''Important Note 1:''' Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).</p><br />
<br />
If your web server is on Windows, use '''php_dblib.dll'''. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) <br />
<br />
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann'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.<br />
<br />
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:<br />
<br />
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.<br />
<br />
{| border="1" align="center" cellpadding="5" style="text-align: center;"<br />
|-<br />
! 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<br />
|-<br />
| rowspan="2" | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]<br />
|-<br />
| rowspan="2" | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]<br />
|-<br />
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]<br />
|-<br />
| colspan="4" | 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 Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!<br />
|}<br />
<br />
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)<br />
<br />
<br />
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&DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&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's site, and save it into your /PHP root directory.<br />
<br />
<br />
3. Edit your /PHP/php.ini file and add this line:<br />
<br />
extension=php_dblib.dll <br />
<br />
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).<br />
<br />
<br />
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 '''freetds.conf''' in the root folder of the server that PHP installed on (e.g. C:\).<br />
<br />
<br />
'''freetds.conf''' should have the following structure:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
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:<br />
<br />
[global]<br />
host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)<br />
instance = xxx (instance name, e.g. INST2)<br />
port = 1433<br />
client charset = UTF-8<br />
tds version = 8.0<br />
text size = 20971520<br />
<br />
<br />
'''Notes:'''<br />
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don't have to use C:\. To do this create a SYSTEM environment variable called '''FREETDS''' 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.<br />
<br />
*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.<br />
<br />
*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.<br />
<br />
<br />
5. Your Moodle '''config.php''' should include lines like these:<br />
<br />
<code php><br />
$CFG->dbtype = 'mssql_n'; // Required<br />
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP<br />
$CFG->dbname = 'moodle'; // or whatever you called the database you created<br />
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)<br />
$CFG->dbpass = 'yourpassword';<br />
$CFG->dbpersist = false;<br />
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.<br />
</code><br />
<br />
If you don'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.<br />
<br />
<br />
6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" 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.<br />
<br />
<br />
7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...<br />
<br />
<code php><br />
<?php<br />
$link = mssql_connect('localhost', 'db_user', 'db_password');<br />
if(!$link) {<br />
echo'Could not connect';<br />
die('Could not connect: ' . mssql_error());<br />
}<br />
echo'Successful connection';<br />
mssql_close($link);<br />
?><br />
</code><br />
<br />
8. Install Moodle as usual. Good luck!<br />
<br />
<br />
=== Troubleshooting ===<br />
If you encounter some problems you can try:<br />
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)<br /><br />
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP (Enable) -> Properties -> Ip Addresses -> 127.0.0.1 (Active+Enable)<br /><br />
*if you are using SQL Server 2005 and you have the error ''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'', try the ODBTP method (next chapter). The SQL Server complaining that it doesn'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't accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(<br />
<br />
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==<br />
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]. <br />
<br />
Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].<br />
<br />
== Using FreeTDS on Debian Lenny ==<br />
I found the following solution using:<br />
* PHP Version 5.2.6-1+lenny9<br />
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00<br />
<pre>apt-get install libsybdb5 freetds-common php5-sybase<br />
/etc/init.d/apache2 restart</pre><br />
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();<br />
<br />
{| class="nicetable"<br />
|-<br />
! MSSQL Support<br />
! enabled<br />
|-<br />
| Library version <br />
| FreeTDS <br />
|}<br />
<br />
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS<br />
<br />
== See Also ==<br />
* [[Installing Moodle]]<br />
* [[Errors FAQ]]<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* [[Beginning Administration FAQ]]<br />
* [[Installing Postgres for PHP]]<br />
* [[Using the Microsoft SQL Server Driver for PHP]]<br />
* [[Installing Oracle for PHP]]<br />
<br />
[[Category:FAQ]]<br />
[[Category:Installation]]<br />
[[Category:Developer]]<br />
[[Category:XMLDB]]<br />
[[Category:DB]]<br />
[[Category:SQL databases]]</div>Stronk7