Server 2016, IIS, SQL 2016, PHP7

Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -
Number of replies: 35
Hello, I currently have a production Moodle runing in Server 2008R2, SQL 2008, PHP 5.6, AD authentication; however, I'm trying to make a development server running Windows Server 2016, SQL Server Express 2016, and PHP7.  I'm not having much luck getting this to work.


Everything is installed and I copied all the Production Data and Folders to the new server.  I've followed all the instructions I can find to make this work, but I keep getting this message:

  • The site administrator should verify server configuration
  • Microsoft Drivers for SQL Server for PHP are not installed or not configured properly.
My php.ini file contains:

[PHP_SQLSRV]
extension=php_sqlsrv_7_nts_x64.dll
; extension=php_pdo_sqlsrv_7_nts_x64.dll

Which should be sufficient, I think.  Files exist.

My config.php file contains:

$CFG->dbtype    = 'sqlsrv';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'sa';
$CFG->dbpass    = 'password';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbsocket' => 0,

If you have any advice on how to get the SQL 2016 drivers to work, please let me know.


Average of ratings: -
In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

Does the PHP errors log file show any error info?

Have you installed the Microsoft ODBC Driver for SQL Server? The SQLSRV driver is dependant on that.

Running Moodle on Windows Server 2016 is very similar to running it on Windows Server 2008 R2. See https://www.linkedin.com/pulse/configuring-php-7-iis-mssql-windows-server-2016-igor-vrabec

And check https://docs.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver (although it doesn't mention Windows Server 2016) to make sure you've configured the IIS and the server correctly for Moodle.

Lastly, don't use ths SQL 'sa' account - $CFG->dbuser = 'sa';  Rather create a different user in SQL Server and use that user.

Average of ratings:Useful (1)
In reply to Luis de Vasconcelos

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

That was useful, but I'm still stuck.  Yes, I do have ODBC driver installed.  I read through those instructions and did a new PHP install, along with new php.ini file and index.php (test).

The test file produced:

PHP Parse error:  syntax error, unexpected '?', expecting end of file in C:\inetpub\wwwroot\index.php on line 2

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Dele sule -

Hi, 

On which host could this codes be use? 

Enlighten me more

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

Anyone?  I've followed steps to the letter.  I cannot get past the PHP Parse error message.

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers
Kenneth, have you looked at the moodle documentation about setting up SQL Server
https://docs.moodle.org/32/en/Using_the_Microsoft_SQL_Server_Driver_for_PHP
In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

Yes, of course.  SQL is not the problem at this point.  If I remove SQL from from php.ini, the test file still doesn't work.

Does anyone know what that error message means?

In reply to Luis de Vasconcelos

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

I wiped the server and started from scratch.  I followed the instructions in your link exactly as they appear.

This time PHP is working, however Moodle does not see the SQL drivers:


"Error: database driver problem detected

The site administrator should verify server configuration

Microsoft Drivers for SQL Server for PHP are not installed or not configured properly."


This is in my php.ini

extension=php_wincache.dll
extension=php_sqlsrv_7_nts_x64.dll
extension=php_pdo_sqlsrv_7_nts_x64.dll

I can confirm the files are there and exists.  Dated 6/29/2016.

I have also tried the ts version and x86 version, just to see what would happen.

Is this an IIS problem?

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

It's definitely not IIS issue, for there had been cases in past showing issues on SQL-Server drivers for PHP, specially for PHP 7. Have you tried using PHP 5.6 just to see if things work smoothly.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

This morning I tried PHP 5.6.30.0 with SQL 4.0 drivers (Not compatible, but I thought I would try)  no success.

PHP 5.6.30.0 with SQL 3.2 drivers (interesting there is no x64/x32 versions).  No success.

I tried a new Moodle install, just in case it didn't like my copy of production.  No success.

SQL error

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Kenneth,

Have a look at this blog post written, with SQL Server installation, you may be missing something required to run SQL Server.

http://www.wicher.co.uk/moodle2012r2/

additionally there is a PDF file with moodle installation on SQL Server HERE.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

Thanks Usman, you've been very helpful.  I still do not have success.  I have to assume SQLSRV32 (drivers for PHP5.6) is incompatible with Windows 2016 Server.

This is in the release.txt file:

SUPPORTED OPERATING SYSTEMS
---------------------------
The Microsoft Drivers for PHP for SQL Server supports the following operating systems:
    o Windows Server 2008 R2 SP1
    o Windows Vista SP2
    o Windows Server 2008 SP2
    o Windows 7 SP1
    o Windows Server 2012
    o Windows Server 2012 R2
    o Windows 8
    o Windows 8.1

So my only option is SQLSRV4 & PHP 7.  Which simply does not work with SQL 2016 on Server 2016.  I have been trying for days, and the information you pointed me to was great, but nothing works.  I can get PHP 7 running no problem, but those drivers are not recognized by PHP.

PHP dll could not be located


I think I will need to build a new Dev server with WIndows 2008R2 and SQL2008.  I've pretty much given up.

In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Though I haven't personally tried SQL Server with moodle before, but will give a try in a few days, just out of curiosity why is that you are choosing SQLServer over MariaDB or MySQL? though  moodle does supports Oracle and SQLServer, but support for either of the two isnt as strong as for MySQL or MariaDB.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

Because we have over 30 virtual servers all running Microsoft SQL, and I have a database expert that knows MS SQL and Access very well.  MySQL would be outside the norm in our environment.

I think I'm closer to an answer.  I believe that swapping the version to 32bit or 64bit of PHP7, might be the solution, I haven't had the time to try it out (I know the extensions are 64bit, I'm not sure I've installed the 64bit executables for PHP).

Average of ratings:Useful (1)
In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Makes sense using MS-SQL.

if you manage to get it working, do update us as well, as I have been trying on 2016 server as well, and no luck so far, as in drivers there is no mention of Server 2016, but as long as Windows 10 is mentioned, it should have worked.

Though support for MySQL/MariaDB is more, but undoubtly IIS + MS-SQL combination will make a very well performing moodle.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

Success!  (mostly)

I made the assumption that all 7.x PHP would be compatible with Microsoft's driver.  I was working with the latest version of PHP 7.1, which is not compatible with the sql driver; however installing PHP 7.0 is compatible!  I do not get a driver error now.

I still have one problem though, now I'm getting the following error:

"Error: Database connection failed.

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php"


Thanks for your help.  On the next problem....

Average of ratings:Useful (1)
In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Ken McKinnon -

For anyone who's using Microsoft SQL Express, put this in your config.php file.

$CFG->dbhost    = 'localhost\sqlexpress';  // eg 'localhost' or 'db.isp.com' or IP

Average of ratings:Useful (2)
In reply to Ken McKinnon

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Cheers Kenneth, Had been waiting to hear something from your side, Now I am assuming this dbhost may only be applicable to SQL Server Express edition, else other server editions will work as described everywhere else.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

I am new to moodle and so far so good. I have set up my server 2016 and configured both my domain (lab-svr.spg.gov.pg) and DNS as well but my problem is accessing my moodle from a client that is joined to the domain. On server 2016 moodle is working okay and have also edited the config.php with the host IP address. 

Now, is there anything else I need to configure on server 2016 so that all clients that join my domain can access my moodle system.

Thank you and much appreciation in advance.

In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Daniel, a domain shouldnt be that long to hold two level sub domains.

when referring to domain, what is that you actually meant? the URL or your local domain?

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

Hi Usman,

This is just a local domain. So far moodle is working fine but I have realised the Windows server 2016 firewall is blocking my windows 10 clients to access my moodle. 

How can I enable the clients not to be blocked by the windows server 2016 firewall? That will sort my issue. 

Thank you.

In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Daniel, this cant be possible that IIS blocks clients for Web Servers are built to serve public and as long as your clients are accessing the server through port 80, they shouldn't be blocked.

Have you made any changes to wwwroot folder regarding access permissions?

if in doubt, I have a tutorial up for setting up moodle on IIS, unless you have been through that already, I will recommend giving it a try and see what different you have done in setting up server and moodle, you can find the tutorial HERE.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

I havent setup IIS yet but will follow up your tutorial and see how best to give a trial.

Thank you.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

I havent setup IIS yet but will follow up your tutorial and see how best to give a trial.

Thank you.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

Hello Usman, So far so good and I have learnt a lot from the videos on the link you sent. 

Now, I am stuck after configuring my PHP on IIS server. See screen shot attached. I can guess its about permission but I have tried and not succeeded. 

Kindly bail me out.

Thank you.

Attachment IIS error-Daniel.PNG
In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

OK its FastCGI error, means something went wrong in setting up PHP.

you have to start again, removing fastCGI settings in IIS settings. have you been using PHP manager to setup PHP?

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

Okay.

I will do it again until I succeed. I will also keep you posted in case of any challenge.


Thank you.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

I was setting using the manual method as Server 2016 seemed incompatible with PHP Manager. All in all will try with the manager once I get a compatible copy. Through the manual method I have learnt quite a lot.

Thanks.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

I am now stuck on HTTP Error 401.3 - Unauthorized. See attached.

All my permissions are set okay. I have even tried to change authentication from Anonymous to Application pool identity but nothing seems to work.

How can I resolve this pleas

Thank you.

Attachment Error 401.PNG
In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Have you given right permission to IUSR to the moodledata folder?

as far as PHP manager is concerned, If you had properly read the post I linked, there are two more versions linked for Server 2012 and Server 2016, which clearly you've missed to say PHP Manager is incompatible. if, you already have settings in FastCGI, remove them before installing PHP manager as it will give error in presence of settings.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

What I meant is there is a php manager for IIS ver 10 which I got and installed. I have already removed all manual settings I had configured including files and started a fresh with Php Manager.

The error of Unauthorized access is after a clean installation and configuration using your video step by step. Where could I haved gone wrong?

I have gives modify rights to IUSR user for both Moodle data and temp folders respectively.

Thank you and awaiting your direction.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

What I meant is there is a php manager for IIS ver 10 which I got and installed. I have already removed all manual settings I had configured including files and started a fresh with Php Manager.

The error of Unauthorized access is after a clean installation and configuration using your video step by step. Where could I haved gone wrong?

I have gives modify rights to IUSR user for both Moodle data and temp folders respectively.

Thank you and awaiting your direction.

In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -

Finally I succeeded and my moodle is running okay. Now challenge is to migrate my data from and old moodle. Please advice best way to do it.

Thank you.

In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Thats a good news at last.

There will be three things that you need to move, if you want to keep moodle intact.

  1. Moodle data folder
  2. Database
  3. Moodle folder

if you had installed any of the PHPMyAdmin, or HeidiSQL, export your database, zip moodledata and moodle folder.

import your DB into your new machine/server using either of the PHPMyAdmin or HeidiSQL application, keep moodledata folder OUT OF WWWROOT folder, but do give IUSR permission to read and write.

hope you wont have any issue importing/transferring, if any, you know where to ask wink

Happy New Year!



In reply to Usman Asar

Re: Server 2016, IIS, SQL 2016, PHP7

by Daniel Kaguongo -
Great!



Now, before I do that kindly advice if it will work with my previous

moodle - because I was using the package for windows that comes with

everything in one folder. I didnt involve any PHPMyAdmin or HeidiSQL

for that matter in setting up my database.



Thank you.
In reply to Daniel Kaguongo

Re: Server 2016, IIS, SQL 2016, PHP7

by Usman Asar -
Picture of Plugin developers Picture of Testers

Daniel, you have to download PHPMyAdmin for the PHP that comes with your installer package, setting up PHPMyAdmin isn't very easy, but not very complicated as well, just follow the instructions in the PHPMyAdmin setting up documentation, this way you will be able to access your DB that comes pre-installed with your Moodle installer.

on second thought, it will be way better if you can export courses from your previous moodle and import them into your new moodle, this will be much easier for you to do rather than setting up PHPMyAdmin and exporting the DB and other required moodle folders.

you can download PHPMyAdmin from HERE.

make sure you're downloading the correct version for your PHP that came with your installer.


Average of ratings:Useful (1)