moodle 2 windows server mysql iis php

17
Installing Moodle2 Windows Server 2008 R2 Installing Moodle 2.0 on a Windows Server 2008 x64 with MySQL, IIS7 and PHP. Written by: Alex Pearce Email: [email protected] Blog: http://www.bfcnetworks.com

Upload: qaisar-abbas

Post on 01-Dec-2014

160 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Moodle 2 Windows Server MySQL IIS PHP

Installing Moodle2 Windows Server 2008 R2

Installing Moodle 2.0 on a Windows Server 2008 x64 with MySQL, IIS7 and PHP.

Written by: Alex Pearce

Email: [email protected]

Blog: http://www.bfcnetworks.com

Page 2: Moodle 2 Windows Server MySQL IIS PHP

1 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Contents Configuring Windows, Roles and Features ............................................................................................. 2

Installing PHP and Configuration with IIS ............................................................................................... 5

Testing IIS and PHP ................................................................................................................................. 7

Configuring the PHP.ini file ..................................................................................................................... 8

Folders and Permissions ......................................................................................................................... 9

Installing MySQL x64 ............................................................................................................................. 11

Configuring MySQL Server .................................................................................................................... 13

Download Moodle ................................................................................................................................ 14

Configuring Moodle .............................................................................................................................. 14

Links and Resources .............................................................................................................................. 16

Page 3: Moodle 2 Windows Server MySQL IIS PHP

2 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Configuring Windows, Roles and Features Install Windows Server 2008 Server R2, give the server an IP address and change the name of the

machine to Moodle then add the machine to your Windows Domain.

Note: This document will not cover the ports that need to be opened on the Windows Firewall.

1. Open Server Manager and navigate down to Security Information. On the panel of the left

hand side you will find Go to Windows Firewall.

2. Navigate down to Firewall Information and on each tab (Domain, Private and Public) turn

Firewall State to Off.

Page 4: Moodle 2 Windows Server MySQL IIS PHP

3 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

3. Back in the Security Information click on Configure IE ESC and turn this off for both

Administrators and Users

4. We will be using Microsoft Internet Information Service to publish our Moodle website. We

will now install this role and add the requirements needed. In Server Manager, Click on Add

Roles and check Application Server and Web Server (IIS).

5. In Web Server (IIS), Role Services ensure the following extras are checked

a. Application Development

i. ASP.NET

ii. .NET Extensibility

iii. CGI

iv. ISAPI Extensions

v. ISAPI Filters

b. Security

i. Basic Authentication

Page 5: Moodle 2 Windows Server MySQL IIS PHP

4 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

6. Click Next and then Install. This will finish off the roles required; you will not require a

reboot following the install.

Page 6: Moodle 2 Windows Server MySQL IIS PHP

5 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Installing PHP and Configuration with IIS

1. Download the latest Non Thread Safe Installer x86 VC9 version of PHP from

http://windows.php.net/download and save it to your Desktop.

2. Run the downloaded MSI from your desktop.

3. Install PHP to c:\php.

4. As we are running PHP with FastCGI we need to install the IIS FastCGI. Select IISFastCGI from

the list and click Next.

5. The default install will install all the extensions we require for Moodle 2.0. Click Next.

6. On the next screen of the wizard click Install which will complete the process of installing

PHP.

Page 7: Moodle 2 Windows Server MySQL IIS PHP

6 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

We are now going to configure PHP with IIS.

1. Open Server Manager and expand Roles down into Internet Information and Services.

Once IIS Manager has opened on the right of the screen click on the name of your server.

2. Scroll down the page and you will find Handler Mappings under the IIS Group.

3. Open Handler Mappings and click on Add Module Map… which is located down the right

hand side.

4. Fill in the small form with the following information

a. Request path: *.php

b. Module: FastCGIModule

c. Executable: C:\php\php-cgi.exe

d. Name: PHPviaFastCGI

5. Click OK to add this extension to IIS. You will then be prompted if you want to allow this

ISAPI and click Yes.

Page 8: Moodle 2 Windows Server MySQL IIS PHP

7 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Testing IIS and PHP We are now going to Test PHP is working on your server through IIS

1. Navigate to c:\inetpub\wwwroot which is the root of your default website.

2. Create a new text file and rename it to testphp.php

Note: If you cannot see file extension to change the file from txt to php in Explorer click on Tools and then Folder Options. Click on the view tab and find Hide Extensions for known file types. Uncheck this option.

3. Open testphp.php in notepad and add the follow code

<html> <head> <title>PHP test</title> </head> <body> <?php phpinfo(); ?> </body> </html>

4. Save the file and open Internet Explorer on the Moodle server. Navigate to

http://127.0.0.1/testphp.php. If you have configured PHP correctly with Internet

Information Servers your page will load and at the top you will have the title of PHP Version

5.2.5 (x64) and look similar to the screenshot below.

Page 9: Moodle 2 Windows Server MySQL IIS PHP

8 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Configuring the PHP.ini file There are a few setting that need to be configured for PHP and Moodle to work correctly. These

changes are made in the php.ini file which is located in the c:\php folder.

1. Open the file C:\php\php.ini in notepad and start a search in the file.

2. Search for doc_root and after the = add the root of your website, c:\inetpub\wwwroot\

3. In a later step we will be create a folder that Moodle will as a temporary location to upload

files. Even though we haven’t created this folder yet we can still tell PHP to use this folder.

Search for upload_tmp_dir. Change both upload_tmp_dir and session.save_path on the

next line to c:\php\sessions.

4. As we are using FastCGI for our Moodle website we need to make some changes to the

php.ini file that tunes the performance of FastCGI with IIS.

Navigate to the top of the page and search for ;cgi.fix_pathinfo and remove the ; comment

from the start of the line.

5. Save the php.ini file.

6. We need IIS to recognise the changes we have just made. We can do this by restarting the

IIS services by opening a command prompt and typing IISreset and pressing Enter.

7. To ensure that PHP is still working navigate to http://127.0.0.1/phpinfo.php and ensure the

page loads.

8. Search for session.save_path within the page and check that this has changed to the new

location we set in set 3.

Page 10: Moodle 2 Windows Server MySQL IIS PHP

9 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Folders and Permissions There are a few folders that are required by both PHP and Moodle. We need to ensure that the

right user has permission to write to these pages otherwise we will have upload issues while trying

to add learning resource to a Moolde course.

1. Navigate to c:\php and create a new folder called sessions.

2. Right click on the new sessions folder and select properties.

3. Select the Security Tab and click on Edit.

4. Click Add and you will be given a new window. By default all users will be searched from our

domain. To change this click on Locations… and select your local server and click OK.

5. Now enter IUSR which is the default user that runs the website in IIS.

Page 11: Moodle 2 Windows Server MySQL IIS PHP

10 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

6. The user will now appear in the permissions tab. By default the IUSR will only have view

access. We now need to give the user write access. Check Modify which will also check

Write.

7. Click on OK to confirm these changes and then click on OK to confirm the Properties

changed.

8. We now need to do the same with the Moodle data folder. Navigate to c:\inetpub and

create the folder c:\inetpub\moodledata.

9. Complete steps 2 to 7 for this folder ensure the IUSR has write permission to the folder.

Page 12: Moodle 2 Windows Server MySQL IIS PHP

11 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Installing MySQL x64 In the current release of Moodle 2 (Release Candidate 1) Microsoft SQL Server is not yet supported

so we are going to use MySQL for the Windows Server.

1. Download the latest version x64 bit version from http://www.mysql.com/ and save the MSI

file to the desktop.

2. Run the downloaded MSI from your desktop. This will start the install process for MySQL.

3. For this install we are only using the basic setup of MySQL. Select Typical from the Setup

Type list and click Next followed by Install.

4. At the end of the Install it will ask you if you want to ‘Configure the MySQL Server Now’.

Ensure this is checked and click Finish.

5. We are now going to configure the default setting to the MySQL application. Select

Standard Configuration and click Next.

Page 13: Moodle 2 Windows Server MySQL IIS PHP

12 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

6. The SQL Instance needs to be kept default. Click Next.

7. The next part of the wizard allows us to set the password for the root administrator account

in MySQL. Set the password to a complex password.

Do not check Create An Anonymous Account.

8. Click Execute to configure MySQL. When this has run click Finish.

Page 14: Moodle 2 Windows Server MySQL IIS PHP

13 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Configuring MySQL Server We now need to create a database for the Moodle website to use. We also need to create user that

has permission to write to the database.

1. Go to Start, All Programs and Open MySQL Command Line Client.

2. Enter the Root Administrator password we inserted during the install process.

3. First we need to create a new database. We will call it MoodleDB. Enter the command be

into the command line tool and press Enter.

If entered correctly you will be given the results that the query ran OK and 1 row was

affected.

4. We now need to create a user that we will use to tell Moodle to connect to this database.

Run this command, creating the user Moodle_User with the password of Password1.

5. Now we need to give the moodle_user permission to the database. Run the following

command, and press Enter.

create database moodledb;

grant usage on *.* to moodle_user@localhost identified by 'Password1';

grant useage on *.* to moodle_user@localhost identified by 'Password1';

Page 15: Moodle 2 Windows Server MySQL IIS PHP

14 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

Download Moodle 1. Download Moodle 2.0 from www.moodle.org.

2. Extract the content of the downloaded zip file in c:\inetpub\wwwroot.

Configuring Moodle 1. Navigate to http://127.0.0.1/ and you will be brought to the Moodle Installation page

2. Select the language you want to use and click Next.

3. The Moodle install will automatically enter the Data Directory which is a

c:\inetpub\modledata folder we created earlier.

If you receive an error message from this screen you have not set the permissions correctly

on the server.

4. From the database type select Improved MySQL (native/mysqli) and click Next.

5. Fill the online form in as below from everything we have configured in previous steps.

a. Database host

i. 127.0.0.1

b. Database name

i. Moodledb

c. Database user

i. Moodle_user

Page 16: Moodle 2 Windows Server MySQL IIS PHP

15 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

d. Database password

i. Password1

6. The next page will try and create a file called config.php in the c:\inetpub\wwwroot folder.

By default the IUSR user does not have permission to write to this folder. Select the content

of the page and copy it to your click board. Create the file config.php in the

c:\inetpub\wwwroot folder. Open the file and paste the content into the file.

If you have followed these steps correctly you will be able to click next in the Moodle install

web page which will then ask you to confirm the term and conditions.

7. Moodle will now complete a check on the state of your environment. Ensure everything is

set to OK. You do not need to worry about the internationalisation extension. When you

are happy click on Continue.

8. Moodle will now create all the tables it requires in the MySQL database. Once it has loaded

the page click on Continue at the bottom.

9. You now need to give your admin account for Moodle a complex password. Also complete

the other fields required. At the bottom click Update Profile.

Page 17: Moodle 2 Windows Server MySQL IIS PHP

16 | P a g e © Copyright: BFC Networks Limited 2010 www.bfcnetworks.com

10. We now complete the final install process by completing information about the education

establishment. Fill in the online form and click on Save Changes at the bottom of the page.

You will now have Moodle 2.0 implemented on your Windows Server.

Links and Resources Microsoft Windows Server 2008 R2

http://www.microsoft.com/windowsserver2008/

PHP

http://windows.php.net/download

MySQL

http://www.mysql.com

Moodle

http://moodle.org/