Windows server: Server 2008, IIS7 MySQL & PHP setup

Windows server: Server 2008, IIS7 MySQL & PHP setup

by Paul Stewart -
Number of replies: 44
Hello everyone,

I've got my self all confused with the vast amount of conflicting advice on the net with regards to the proper installation of Moodle on a server 2008 environment. Its server 2008 32 bit ed running as a webserver with IIS7 and FastCGi installed.

I have used the non-thread safe build of PHP and will use MySQL too. At first i used SQL server 2005 but found out this was no good.

I set up php and run php -i in command prompt and it floods with text so i assume its working, however if i create a php file with the php info and place it in the wwwroot folder, i get a internal 500 error.

My installation of moodle is in C:\inetpub\wwwroot

I have set up a site in IIS 7 and pointed it to this location.

I set up MySQL via this site and successfully created the moodle database with the user being moodleuser.

I just wanted to know if i'm doing things right of should i just go back and start again using server 2003 and IIS6?

thanks

Paul
Average of ratings: -
In reply to Paul Stewart

Re: Windows server: Server 2008, IIS7 MySQL & PHP setup

by Keshwar White -
Hi Paul,

You can follow my instructions.

First let me know, Are you willing to start from scratch?
In reply to Keshwar White

Re: Windows server: Server 2008, IIS7 MySQL & PHP setup

by Paul Stewart -
Yes i'm quite willing to start from scratch. On Monday morning i'll be re-installing server 2008 just so i know that its a clean slate.

thanks for your reply
In reply to Paul Stewart

Re: Windows server: Server 2008, IIS7 MySQL & PHP setup

by Keshwar White -
Paul, you really don't need to go back that far but if you do, do not install IIS7 from server roles.

If you do not want to reinstall Server 2008, you can do this:

  1. Point your "default web site" back to /inetpub/wwwroot/
  2. The run "start /w pkgmgr.exe /uu:IIS-WebServerRole;WAS-WindowsActivationService" from the elevated command prompt (start->right click on command prompt -> run as administrator)
  3. Restart the computer
  4. Uninstall MySQL if installed
  5. Remove/delete PHP directory that you installed
  6. You should be clean.
I will walk you through a rock solid IIS7/MySQL/Server2008 setup that will run any PHP App you want (moodle, joomla, etc).

-Keshwar
In reply to Keshwar White

Re: Windows server: Server 2008, IIS7 MySQL & PHP setup

by Paul Stewart -
Came in first thing to do this Keshwar. Its all done as per instruction smile

Thanks for your help

Paul

In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Ok let's get started:

Download the following to your desktop (do not Install):

Web platform 2.0
Xamp for Windows
MySQL Essentials

After you finish downloading these, Install the web platform 2.0 Installer with these options (Select web platform tab on the left):

  1. Web Server (Click Customize)
  • Common HTTP Features
    • Static Content
    • Default Document
    • Directory Browse
    • HTTP Errors
    • HTTP Redirection
    • URL Rewrite 1.1
  • Application Development
    • ASP.NET
    • .NET Extensibility
    • CGI
    • ISAPI Extensions
    • ISAPI Filters
    • Server Side includes
  • Compatibility
    • IIS Metabase and IIS 6 Configuration Compatibility
    • IIS 6 Management Console
  • Deployment and Publishing
    • FTP Management Console
    • FTP Publishing 7.5
    • Web DAV 7.5
  • Health and Diagnostics
    • HTTP Logging
    • Logging Tools
    • Request Monitor
  • Management (Choose All Features)
  • Media (Optional)
  • Performance (Choose All Features)
  • Security
    • Request Filtering
  • WAS (Choose All Features)
Frameworks and Runtimes (Click Customize)
  • .NET Framework
    • .NET Framework 3.5 SP1
  • PHP
    • PHP 5.2.8-2
Now Click Install. Your computer will need to be restarted so check back with me when installation is complete. Let me know the if installation was successful smile ( To Check type localhost, into your web browser and tell me what you get)
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Hi Keshwar,

I installed Webplatform like you said and restarted. I look to local host but just get the 'Page cannot be displayed' Is this supposed to happen?

thanks for your help on this,

Paul
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Two things:

Open IIS Manager and make sure that your sites are running

and

Have you ever altered your host file?
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
in the original install some features were missing, so i took away the WEB server role and reinstalled the WPI. I have altered the host file before by commenting out the ::1 line.
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Sorry Keshwar i'm being a total nub here i think.

I cant even get my test.php file to show. Its in inetpup\wwwroot with this code in the file

<?php phpinfo();?>

Re-installed the WPI exactly how you desribed, the IIS6 compatability mode was missing from the last attempt.
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
make sure your host file slooks like this:

127.0.0.1 localhost
::1 localhost


If you have a public address for moodle i.e "learn.example.com"

127.0.0.1 localhost learn.example.com
::1 localhost

also in IIS Manager a make sure bindings on your Default Web Site is set to "All Unassigned"
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
My host file was sorted and my bindings are set to All unasigned.

I have the Moodle folder in the wwwroot, and pointed the default document to index.php. Now when i look to localhost i get this http error 404.3
'The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.'

Should i have installed the MySQL essentials and xampp? i havent yet but as you can tell i'm the moodle virgin sad

In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
take the moodle or anything related to it out of the wwwroot

we will get to that later
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Now We will install XAMPP, run the installer

  • OK to the vista notice
  • intsall to the C:\xampp\ folder
  • SERVICE SECTION (important!!)
    • All boxes unchecked!!!
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Thats done to the letter and it installed successfully smile
i have a Xampp control panel on the desktop
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Next lets install MySQL, although it is best practice to install this on a separate machine, it would not be a problem or cause you any harm to put it on the same server. (If you don't have another server and would like to host it separately , I can host unlimited databases for you for only $9.95 per month)

This installation is tricky on Windows Server 2008, so please follow closely. It seems like no one but me of course smile can install MySQL on Windows Server 2008 without errors.

  • Run the installer
    • Select Custom
    • click on "MySQL Sever Datafiles" then click "Change.."
    • Change folder name to: C:\MySQL\MySQL Server 5.1\
    • Click next until... Wizard complete
    • Configure the MySQL Server now (CHECKED)
    • Click finish
  • MySQL Server Instance Config
    • Detailed Configuration
    • Server Machine
    • Multifunctional Database
    • Click next to..
    • Inline Transacftion Processing (OLTP)
    • Check the "add firewall exception for this port"
    • Best Support for Multilingualism
    • Change service name to MySQL51
    • Uncheck "Modify Security Settings" Important
    • Execute
Now click start -> All programs -> MySQL -> MySQL Server 5.1 -> MySQL Server intance Config Wizard:

  • Reconfigure Instance
    • MySQL Server Instance Config
      • Detailed Configuration
      • Server Machine
      • Multifunctional Database
      • Click next to..
      • Inline Transacftion Processing (OLTP)
      • DO NOT Check the "add firewall exception for this port"
      • Best Support for Multilingualism
      • Change service name to MySQL51
      • Check "Modify Security Settings" Important
        • Current password blank
        • Enter new password
        • confirm
        • check enable root access
      • Execute
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Hi Keshwar,

Thanks for that, its all done. You must have replied after i left last night, sorry about the delay.

Paul
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Good, Next create a folder "c:\WebApps"

Then inside that folder you are going to create another folder "Moodle1" you can now extract Moodle zip file into the c:\WebApps\Moodle1\


In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Is there a couple of more steps after this? Its just so i can work on it for most of the day. I appreciate the time you have spent on this Keshwar .

I think before i set it up you should know that this moodle site is for a Private school. I am the IT support technician for the school but my opensource knowledge is minimal.

i would like it to be linked into our current website in some way http://www.theglasgowacademy.org.uk and I know that some ISA server configuration will be needed however i think i'll be fine once i get the finer points of just setting it up.Also i wanted to set it up so that our users can use their Windows domain logins. Thats the only way my boss wants it set up. Our site is on its own webserver, however the moodle set up is running on a test server but only a Dell Optiplex 745 PC running server 2008.

If i set it up successfully we will buy in a dedicated server for moodle.

Like i said i really appreciate the help with this smile

Paul
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
Yes there are a few more steps, do you have skype? I can help you faster that way, but I will still post the instructions here on moodle for everyone else. ISA would not be a problem. Are you in the UK?
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Time really isn't an issue Keshwar, but yes i am in the UK in Glasgow, Scotland.

I don't mind following the steps - I couldn't commit to Skype contact due to the nature of the job, they expect me to just drop everything when theres a problem.

I've created these folders..
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
Keshwar,

you'll be pleased to know that i re-installed Server 2008 and followed the steps again. I know get the IIS.htm showing when i look at localhost.

It was obvious my tinkering before had done something to the setup.

Ta
In reply to Paul Stewart

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Keshwar White -
So you created all the folders?
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Paul Stewart -
yes i created all the folders and unzipped the moodle 1.9.4 build to the moodle1 folder.

one thing...the moodle1 folder now contains a Server folder and a startmoodle and stopmoodle file. Shouldnt it not just be the moodle directory thats in the folder?
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 1

by Stefano Posti -

Hello Keshwar,

I'm following close your instructions because I have has the same problem that Paul had... what should we do next after creating the Webapps folder?

Many thanks, your instructions are the only one really working until now!

MySQL is correctly installed on my Win2008 32bit Server, and I already had FastCGI running on IIS7... though, Moodle install.php won't start for some ackward reason ...

Now I'm following your instructions, I really need Moodle running and I wouldn't like to use Apache...

Stefano

In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Keshwar White -
OK LET'S Continue.

Now we are going to configure PHP on Windows Server 2008 the right way. If you were following my directions to this point you should have 2 PHP Installations.

  1. c:\program files\PHP (B.S.)
  2. c:\xampp\php (Real)
I want you to open IIS7 Manager, then click on your server name than follow:


  1. Find "Handler Mappings" icon and then double click it
  2. Find "PHP_via_FastCGI" then double click it
  3. Under Executable (Optional): change to c:\xampp\php\php-cgi.exe then click OK
  4. The next dialog that pops up click "Yes"
  5. Click on your server name again in the left pane to bring up all the icons
  6. Find "FastCGI Settings" and double click
  7. You should see two lines
    1. c:\program files\PHP\php-cgi.exe
    2. c:\xampp\php\php-cgi.exe
  8. Double click the 2nd (c:\xampp\php\php-cgi.exe )
  9. Click the word (collection) then click the little grey button to the right:
    1. Click add on the left, then on the right change the word "Name" on the right to PHP_FCGI_MAX_REQUESTS the value to 10000
    2. Click add on the left again, then on the right change the word name "Name" on the right to PHPRC and the value to c:\xampp\php\
    3. Click OK
  10. Change "InstanceMaxRequests" to 10000
  11. Close your IIS7 Manager
Next we need to edit the php.ini file. Well, I guess you don't need to edit becuase I attached it. Just replace the one in c:\xampp\php\
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Hobie Baker -
Hi, I've been following this install and so far all is well.  Will you continue soon?  I need help with the rest.  Thanks, Hobie
In reply to Hobie Baker

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Keshwar White -
Hi, I will continue the instructions over @ gyreconsulting.com

This way I can respond, while I do my job. just click here

subscribe for the updates.
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Simon Manning -

Hi,

I've been following the installation steps, posted by Keshwar, but it seems to have stopped halfway through.  Does anyone know where i can find the remaining steps.

I've clicked on the link posted by Keshwar and i can't find anything

In reply to Simon Manning

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by curt danforth -

http://www.gyreconsulting.com/Windows-Server-2008R2/2-How-to-Install-IIS7-and-PHP-on-Windows-Server-2008

This is the link that looks most useful.

I had IIS7 setup with PHP and installed MySql.
Like this thread PHP was working fine but could not connect to the mysql database.  My error was that the Mysql server is not responding.

I downloaded the Microsoft Web Platform Installer 2.0 and followed the notes on link above to complete an install.  The phpMyAdmin setup on my IIS server is now connecting correctly to MySQL. So now will complete Moodle install.

In reply to curt danforth

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
you can go one step better than the above link and use the installer here:
http://www.microsoft.com/web/gallery/Moodle.aspx

which uses the Web platform installer and also installs Moodle as well as IIS/PHP etc..
In reply to Dan Marsden

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers
Dan, does that Microsoft installer create a secure Moodle website that's suitable for production?
In reply to Luis de Vasconcelos

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Keshwar White -
Installing Moodle via Microsoft Installer on the root of your site is not suitable for production.
In reply to Keshwar White

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I'm not what Keshwar is basing his information on, but IMO it gets very close.

Couple of things that need to change after installation
1: $CFG->wwwroot - needs to be an actual url instead of using the calculated method guessing the url from server headers.

2. Ideally $CFG->dataroot should be moved outside the webroot - the WPI doesn't allow you to manipulate directories outside the webroot - it does use a web.config file to "protect" the files from being accessible, but it's not really great practice.

The old version of the installer (currently the public one at the moment) doesn't force you to use a nice secure DB password and doesn't set up the password salt (the new one which I hope MS will review at some point in the next few weeks) does.

Keshwar mentions "on the root of your site" - the WPI installer places moodle in a sub-directory on the website that you select (if only one is installed it just uses the "default" website which should be fine)

Keshwar - have you used/seen the WPI installer? - could you please elaborate on what you mean by not suitable for production and why?
In reply to Dan Marsden

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Joshua Westerway -
Dan,

I have just installed moodle via the WPI, all seems well (PHP works fine, phpmyadmin works fine), except during moodle install when the installer script tries to use C:\inetpub\moodledata as the files path it is not allowed to do so, due to the permissions applied to the web server.

How can we modify the security settings to allow moodle to use a datadir outside the wwwroot folder? as normally accepted on other installs.

Cheers,
Josh
In reply to Joshua Westerway

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Joshua, Unfortunately the MS WPI installer doesn't allow us to control modify any files outside the webroot I have included a web.config file which will protect the datadir from direct access but it's still good practice to move this outside the webroot (esp for production installs)

After the installation is complete you will need to perform this step manually by moving the directory somewhere else, assigning appropriate permissions and updating the config.php with the detail.
In reply to Dan Marsden

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Joshua Westerway -

Dan, OK so manually move the moodledata folder then change config.php to suit the new path, but doesnt the server still disallow file actions in the new data directory path as it is outside the webroot?

In reply to Joshua Westerway

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
you'll need to set up file permissions as per usual to allow your web user to write to that directory - just creating a directory on your server and pointing Moodle at it won't work.

Check out some of the full Windows install instructions for how to create a moodledata directory and give your web user access to write to it.
In reply to Dan Marsden

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Terrance Bennett -

I just ran the installer from the link posted above http://www.microsoft.com/web/gallery/Moodle.aspx

This works great and the only configuration needed was in IIS7, point the "default web site" to the moodle directory, added the host header and away it goes... Up and running in less than 30min.

The installer will install

FastCGI, Web Deployment Tool, MySQL, PHP, Windows Cache Ext for PHP and MySQL Windows Essential.  See attachment

Thanks.

Attachment MS_Modle_Install.PNG
In reply to Terrance Bennett

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by a k -
Hi, I needed help with Installation of moodle.
I have installed apache 2.2.14,php5.2.13 &mysql 5.1.46 on windows 2003 server. when i am calling install.php it give an error "The page cannot be displayed". Can u help???
In reply to Terrance Bennett

Re: Server 2008, IIS7 MySQL & PHP setup Part 2

by Chris Nelson -

Can the present (web platform Moodle version 1.9.x be upgraded to version 2.x?

In reply to Paul Stewart

Re: Windows server: Server 2008, IIS7 MySQL & PHP setup

by Jose Garcia -

Give me.. your email, im going to send you my php files .. im running ws2008rs, SQL SERVER r2 2008 and php 5.14 all this are for moodle 2.0