Installing Moodle & PHP on Windows Server 2008R2

Installing Moodle & PHP on Windows Server 2008R2

by Johnny Bee -
Number of replies: 22

Hey all, 

First, pls fogive my noobishness, this is my first attempt of installing moodle.

I have scoured the docs and forum but it's making my head hurt and I can't find the help I need.

I'm having a lil' trouble installing moodle & PHP on Windows Server 2008R2 (x64)... I /may/ have got past the PHP stage but want to double check if I've done things right...

So I followed the link to the instructions "Installing Moodle on Windows Server 2008 R2" - however they seem out of date for the PHP side.

So /please/ tell me if I have done this correct or wrong...

Page 6.1 The PHP download does not exist.  I downloaded the 5.3.5 x64 PHP zip elsewhere... BUT then...

Page 6.2 php.ini-recommended does not exist.  So I used php.ini-production instead.  BUT then...

Page 7.8 c:\php\php5isapi.dll does not exist! ... after a lil' googling I found that it is no longer used...

Sooooo.... I intsalled CGI component of IIS7 and then made both the FastCGI Module Map AND Script Map point to c:\php\php-cgi.exe and my <?php phpinfo();?> appears to be working... But I have no idea if this is acutally right or if it's just going to byte me in the butt later on.

AND I have no idea what to set the value of open_basedir to in the php.ini file.

Can anyone please offer me some advice or at least link me to a current php + moodle installation guide for Windows Server 2008 R2.

Much appreciated.

Johnny

Average of ratings: -
In reply to Johnny Bee

Re: Installing Moodle & PHP on Windows Server 2008R2

by Colin Fraser -
Picture of Documentation writers Picture of Testers

if you have succesfully run the PHP info command, then you have properly installed PHP. Follow the instructions in the php.ini file, (that is the php.ini-distro renamed usually). There are some things that specifically relate to IIS and Windows, and are mentioned there, fast-cgi is one of them. Make sure you have the right dynamic extensions uncommented though. I understand the the use of the php5isapi.dll is not essential any more, but it I am pretty sure it is still available if you go to the PHP web site and look at the PECL extentions library, you may find it there or if you look here, you can download it. From memory, there was another dll file asked for, but equally unneccessary, but I downloaded them both, and put them into the php root folder rather than as a dynamic extension and it worked anyway. I think they were there as just in case legacy items, but not really required though.

For more information, and I understand that most Windows use the same basic configuration for IIS, you may want to try this rather "exciting" video

for additional information. To make it a bit easier for yourself, you may want to think about using the MS Web Platform Installer...

In reply to Colin Fraser

Re: Installing Moodle & PHP on Windows Server 2008R2

by Johnny Bee -

Thanks for your reply Colin.

I'll make myself another coffee and watch the video.

Are there any current installation instructions?  none of which I have read on moodle.org accurately reflect the actual installation / config process.

Where do I find the 'MS Web Platform Installer'? I most certainly DO want to make this easier.

 

...  I've obviously done something wrong as I've got through the config part of moodle, however now get a 404 message when trying to access moodle:

<server>/admin/index.php?sessionstarted=1&sessionverify=1&lang=en

 

In reply to Johnny Bee

Re: Installing Moodle & PHP on Windows Server 2008R2

by Colin Fraser -
Picture of Documentation writers Picture of Testers

You can download the installer by going to this MS page and downloading it. I understand it installs stuff, and I am sure it will work, but it is Microsoft.

Installing Moodle is something of an adventure the first few times you do it, things go wrong and, I found anyway, every time the error could be traced back to something I thought I could, or should, do and could not.

The documentation for installing Moodle on recent versions of Windows is dated, confusing and no longer reflects accurately what needs be done. Now I have the time to fix that, I no longer have access to the server to be able to show how it is done or take grabs or make videos of what I am doing. Still, I am thinking of something else which may or may not work, depends if I can get someone to let me do it... who knows.

In the mean time, I am recommending to everyone who wants to try this to follow what advice they can get from whatever source they can get it from and do it, one step at a time. See what works, what does not, and keep a record of what you do. When you have been successful, if you have the time, write it up as a Moodle Doc, or kick it over to Moodle.org, someone else may be able to write it up. Good luck.

In reply to Johnny Bee

Re: Installing Moodle & PHP on Windows Server 2008R2

by Alexandria Hayes -

im getting this exact error on our Moodle 2 attempt. We are also running on 2008 r2 but we are using sqlserv instead as we prefer that to mysql.

if you can look at the webpage on the server itself you may get an error about sessions. if this is the case then we have the same problem. sessions are being created in the sessions table (and after some ipv6 issues) they are storing sessions and ips. however it is still moaning about the lack of ability to initialise sessions.

does anyone know if sessions are stored elsewhere than the database as well? also why am i getting a moodle page that tells me there is a problem with sessions on the server but from another machine i get a 404 error?

Alex

In reply to Alexandria Hayes

Re: Installing Moodle & PHP on Windows Server 2008R2

by Johnny Bee -

Hi Alex,

Since my initial post I have reinstalled the server and everything fresh for the umpteenth time, and yes, appear to be having exactly the same problem. (but with mssql)

404 errors while trying to run the initial moodle config and subsequently when trying access moodle from a client PC.

"Can not initialise PHP session." when trying to access moodle on host server.

CAN access website from both client and host PC, eg. my phptest.php and a dummy html file in wwwroot browse without error.

If you find a solution Alex, please remember me and let me know :D

I will be sure to do the same!

Cheers

In reply to Johnny Bee

Re: Installing Moodle & PHP on Windows Server 2008R2

by Alex Pearce -

Hi,

I wrote the PHP whitepapers and have not had chance to update the files yet with the new version of PHP.  If you use this whitepapers which is how to configure Moodle 2, it will tell you how to compile PHP using the current version.

I've got a bit of time in 2 weeks so will update them all then

http://www.bfcnetworks.com/whitepapers/installing-moodle-2-on-windows-server-2008-r2-x64-sql-iis/

Alex

In reply to Alex Pearce

Re: Installing Moodle & PHP on Windows Server 2008R2 - fixed?

by Alexandria Hayes -

Hi!

 

I have managed to make it work, after going through your (Alex) white paper and double checking everything, today i spotted something. One of the not-required php extensions was installed on your documentation, and not on our servers. after adding it to our php the whole thing kicked in and worked like a dream.

The extension in question was "XMLRPC" get it uncommented and it should all work. if its already in there, make sure only the localisation extension isnt installed and all the rest are there and working.

Hope this helps anyone else with the same problem. Now i can actually play with Moodle 2!

 

Alex

 

p.s. this is with a fresh install attempt with Moodle 2.0.3+

In reply to Alex Pearce

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

Hello Alex (and anyone else able to help !!)

Excellent guide .. finally something that makes sense.  A lot of the other ones fell short one way or another for this modern installation... (Window 2008, IIS 7, SQL Server 2008) .

However, I do have a problem when starting the final steps. I've copied the latest Moodle version into the wwwroot and correctly see the configuration sceens for the moodle application.  However I'm not allowed to select the SQL database, it keeps defaulting to the MySQL option. I've downloaded the version 2 and 1.9 options from this site but there is no difference (in database selection terms).

Where did you get your moodle pack with the SQL option to install from ?

Regards Adrian

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -

Hi Adrian,

I used Alex's guides too - and agree - they are excellent.

Which Moodle are you using?  for 2.x you'll need to identify the SQl Server driver in your php.ini file:

[PHP_SQLSRV]

extension=php_sqlsrv_53_nts_vc9.dll

Then make sure the above referenced DLL is in your php\ext directory.

If you're using below 2.x, you'll need to use FreeDTS:

http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip.

Extract the php_dblib.dll to your php\ext directory and reference it in your php.ini file as:

[PHP_DBLIB]

extension=php_dblib.dll

Have a config file in the root of your C drive with:

[global]
host = yoursqlserver.yourdomain.com
port = 1433
client charset = UTF-8
tds version = 8.0
text size = 20971520
dump file = c:\inetpub\moodledata\freedts.log
debug level = 1

You can have the log file dump to where you would like.

Cheers!

 

In reply to Jim Bennett

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

Hi Jim

Yes I have checked I have the right dll present (loading v2.) ... php_sqlsrv_53_nts_vc9.dll

Its correctly referenced in the php.ini file.

However until now there has been no mention of a config file in the root... (I don't have one other than the config.sys ). Is that needed for the install part of the moodle php to see sqlsrv rather that mysql  which it is doing ?

Regards Adrian

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -

Hi Adrian,

It depends on your version of Moodle: version 2.x uses the php_sqlsrv_53_nts_vc9.dll and only needs to be referenced in the php.ini file.  Version 1.9.x & lower needs FreeDTS, which needs the freedts.config file in your drive root.

Since I'm not sure which version o Moodle you are using, I referenced both for you.  Keep in mind that ALex's instructions are specific to each version of Moodle, so don't use the instructions for 2.x if you are on 1.9.x, and vice versa.

Let me know if you're still stumped, and I'll try to help you diagnose it.

In reply to Jim Bennett

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

HI

Yes its still not playing correctly. I'm trying version 2 and yes ..  php_sqlsrv_53_nts_vc9.dll and is referenced in the php.ini file

I have used his instructions totally but the config file you mentioned was only mentioned earlier in 1.9 .. it makes sense that moodle knows about the SQL datebase being used .. but thats surely the point of the initial configuration .. and I'm only being offered MySQL that I don't even have installed (MS SQLServer 2008 only).

Its as if the moodle installation file is defaulting to MySQL and ignoring anything else installed on the machine or referred to in the ini file.

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -

Interesting.  Since you have it in php.ini and the DLL in the correct place, Moodle should pick it up. I take it from you comment that it is only seeing MySQL and no other database options at all?

I'll go through my notes this aft, and see if I made note of something I ran into.  We built a pilot 1.9.x and a 2.x server so I want to make sure I don't mix up suggestions for you.

You won't need FreeDTS for version 2 so ignore those instructions.

 

In reply to Jim Bennett

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

Many thanks .. no no other options regarding databases .. just MySQL which is strange. I've even commented out the MySQL references in the ini file (in C:\PHP\ directory ! (yes it is the only PHP directory).

Incidentally the server is a 2008 clean install, (for this ) fully patched, IE9, Net4  .. SQL Server 2008 installed and then the latest PHP version installed. That all seemed to work .. in that PHPinfo returned information correctly.

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -
OK - that's puzzling.  Here's a few things that you've probably already checked, but I'll run 'em past you anyway ...
One thing to check is that the php.ini file you think is load is the one loading (though you may have already done this).  I know when I was flailing around at first I saw some posts indicating it should be in the root directory, so dutifully created it there, and caused myself all sorts of red-herring chases after!!!!
Create a page in your wwwroot called testphp.php.  In it put:
<head>
<title>PHP Test</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>
Then navigate to this page (i.e. http://myserver.com/testphp.php) and scroll to find the entry Loaded Configuration File.  It should point to c:\php\php.ini.
In the php.ini file, make sure the extension directory path is correct:
extension_dir="C:\php\ext";
Also, with the aforementioned test page, scroll down to see which databases it lists. You should see a section called mssql under which will be tabular info about the driver configuration. You will porbably also see MySQL, MySQLi, ODBC, to name a few.
Is your SQL Server 2008 R2?  If not you should change it up.  This won't account for you not seeing it, just a technical caveat.
Check these things out if you haven't already, and I'll ponder this some more.  I'm not a guru, so I may have to pass the ball if we don't stumble across the issue ...
In reply to Jim Bennett

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

In the Configure Command part of the output is a list .. and it says "--without-mssql" "--without-pdo-mssql" ...

yet the rest of the ini file seems complete with the right file mentioned .. ..  php_sqlsrv_53_nts_vc9.dll is referenced in the php.ini file

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Deleted user -

according to alexs guide at http://www.bfcnetworks.com/whitepapers/installing-moodle-2-on-windows-server-2008-r2-x64-sql-iis/ entitled install-moodle-2-on-microsoft-sql-server-windows-server-2008-r2-and-iis. The guide is out of date. in the guide it has you goto a fusionxlan.com to download a phpx64 edition that the guide calls for. I tried looking all around for the download but the website no longer exists. I have tried alternatives all with php errors to database errors on the site. Im trying to use the latest moodle version with 2008 and 2008 microsoft sql. I have no clue what to do ive been trying to get this working for about a week. Every guide I go through leads to failure so far. I need to get this setup for my work at the company im with.

 

After following the above comments when i get to the sql database setup on the moodle screen i get the following error while conectiong to the mysql database

"

Error: database driver problem detected

The site administrator should verify server configuration

PHP has not been properly configured with the MSSQL extension so that it can communicate with SQL*Server. Please check your php.ini file or recompile PHP. "

 

any help?

In reply to Deleted user

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -

Yes - that fusionxlan link is not correct.  Go to http://windows.php.net.download and get the latest non-thread safe x86 VC9 version.   I'd recommend downloading the full package and installing instead of using the installer.  You may need to add additional components (such as LDAP) which the installer doesn't provide by default.

Also, I needed to install the SQl Server native client.  I think this was because I was connecting to SQl Server on a cluster instead of the local machine, although my first assumption was that the sql server driver I referenced above should handle this.

In reply to Jim Bennett

Re: Installing Moodle & PHP on Windows Server 2008R2

by Adrian Jones -

Ah problem sorted .. it seems as if I should not be using the windows variant despite it being installed on a windows box. The ordinary installation gives the MS Sql option .. whereas the windows one forces you down the mysql route.. very strange !!

 

Thank you Jim !

 

In reply to Adrian Jones

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jim Bennett -

Glad you got it sorted!  Yes I agree - it's very confusing that the Windows variant is the one you shouldn't use!!!!  I haven't quite got my head around that one either.

Cheers!

In reply to Alex Pearce

Re: Installing Moodle & PHP on Windows Server 2008R2

by Jo Lewis -

Your Whitepaapers worked a treat..... thanks

 

Koffee