installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Number of replies: 20
Picture of Plugin developers

Hello, I am getting the below error while installing Moodle on Ubuntu 16.04 and Database server on windows 2012, MSSQL 2014.

error

Average of ratings: -
In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Usman Asar -
Picture of Plugin developers Picture of Testers

Shiva, have you used correct driver for PHP of SQL server? as there are updated drivers for PHP 7.

In reply to Usman Asar

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

Hi Usman

I did install the sql Driver for PHP 7 but it still unable to connect tt

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It looks like it is still using php5 - you need to disable php5 and enable php7.  Not sure how exactly on windows but I am sure you can google it.

In reply to Emma Richardson

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

HI Emma PHP7 is enabled


ee

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You have only proved that *command line* PHP 7 is enabled. This is nothing to do with PHP through the web server. 

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Have you installed php7.0-mysql?

In reply to Emma Richardson

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

Yes Emma PHP7 and mysql is installed and operational

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Usman Asar -
Picture of Plugin developers Picture of Testers

Shiva, since your PHP is running on Linux, so are you using the correct driver, for yuo may not be using the SQL Server driver for Windows platform.

Please download Microsoft's ODBC driver for SQL Server, instructions for distros are HERE.

In reply to Usman Asar

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

Hi Usman

I have installed the ODBC, I Have also tried connecting to Do through php code but i still got this error:

" Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in /var/www/html/test/test.php:9 Stack trace: #0 {main} thrown in /var/www/html/test/test.php on line 9"

this is my code:

<?php
$serverName = "HOST";
$connectionOptions = array(
    "Database" => "test",
    "Uid" => "USERNAME",
    "PWD" => "PASSWORD"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn)
    echo "Connected!";
?>



In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Usman Asar -
Picture of Plugin developers Picture of Testers

what have you written in $CFG->dbhost in config.php file?


In reply to Usman Asar

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

hi Usman I have managed to get it connected and installed successful, the problem was that my .pdo and .so extensions were not included in the apache2/php.ini file.

now while m trying to connect to the external DB: f 

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Ken Task -
Picture of Particularly helpful Moodlers

What do you see in /etc/php?   a 7.0 or 7.1 directory there?

Your screen shot shows there is no reference to the .so files for sqlsrv nor pdo_sqlsrv. ... that's the line 0 stuff.   Those are normally just single lines in an .ini file named for the extension ... like pdo_sqlsrv.ini ... such as below.

In

/etc/php7/apache2/php.ini
is there a line for
extension=sqlsrv.so
ditto for pdo_sqlsrv.so

If not, add the lines, restart apache, then check to see if the extensions are loaded:

php -m |grep sqlsrv

OR

phpinfo page dropped at document root should show you everything about php on your server.

Those .so files should be in /usr/lib/php/20151012/

'spirit of sharing', Ken


In reply to Ken Task

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

Thanks Ken

now m facing this new error ss

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Ken Task -
Picture of Particularly helpful Moodlers

Am a linux guy ... dumped windows many many moons ago.

The error, however, is a DB error and not the typical Moodle error screen one sees (yellow background with rounded box surrounding the error) ... might be debugging?  Are you now seeing a Moodle screen without logging on?  How about googling for the SQL state error number and the Error code number?

https://support.microsoft.com/en-us/help/2121736/error-message-when-you-try-to-authenticate-an-odbc-connection-to-your

And the error screen you see, does hint at config.php ... maybe the DB user (sa), DB pasword?

So check config.php ...

Find a test php script you can program to test connectivity as well.

Maybe one found below?

http://php.net/manual/en/function.sqlsrv-connect.php

Must confess, haven't seen many who use the combo of Ubuntu with MSSQL on db.   While you have had a few 'regulars' in the forums here attempt to help, think you'll find there are few that run that combo ... this to say what help you get might really be guesses.

Heard rumor that Microsoft was building a mssql for Linux.   As long as you are kinda on bleeding edge, why not get waaaaayyyyy out there! ;)

'spirit of sharing', Ken

In reply to Ken Task

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

awesome thanks Ken Managed to connect to the DB now all set just needed to create moodle DB and give sa account all ok now smile

However I want to put my enrollments through the external Database plugin now when I connect it through that is gives me this error:

tr

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Ken Task -
Picture of Particularly helpful Moodlers
The second error says mssql not loaded.
php -m |grep mssql
Also check the phpinfo link under server in Moodle Admin interface for extensions that are loaded and to see if apache sees them also.

Also check apache error logs as well as DB logs.

Turn on debugging for more info then try setting up the enrolment again to see if Moodle will report more info.   [now don't ask me how to fix ... roll up sleeves and learn to dig! ;)]

@Usman ... this one is beginning to get out of my area of 'experise' (whatever that means) ... when it comes to the Windows end things.

'spirit of sharing', Ken



In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Usman Asar -
Picture of Plugin developers Picture of Testers

Which external database is it? the same on SQL Server or some other.


@Ken, its not windows any more, now it's related to moodle for you've fixed the major issue wink

In reply to Usman Asar

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

hi Usman,

this is a dif DB but on the same SQL server :/

In reply to Shivanesh Lal

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Usman Asar -
Picture of Plugin developers Picture of Testers

Sorry I meant to say, is if you're importing users from a different DB.

In reply to Usman Asar

Re: installing Moodle on Ubuntu 16.04 and Database server on win 2012 MSSQL 2014

by Shivanesh Lal -
Picture of Plugin developers

I am using the user enrollment to course from external DB my users are linked from LDAP