I am following this link to be able to setup Moodle on Ubuntu. Moodle command line instructions. I am getting a failure at line 187 in the /lib/installlib.php. I have put in the correct information about the DB connection (username, pw, etc). I normally install through the moodle web interface. I am wondering if anyone has successfully installed moodle through command line interface with Moodle 4.x before??
/**
* This is in function because we want the /install.php to parse in PHP4
*
* @param object $database
* @param string $dbhsot
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $prefix
* @param mixed $dboptions
* @return string
*/
function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix,
$dboptions) {
if (!preg_match('/^[a-z_]*$/', $prefix)) {
return get_string('invaliddbprefix', 'install');
}
try {
try {
$database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
} catch (moodle_exception $e) {
// let's try to create new database
if ($database->create_database($dbhost, $dbuser, $dbpass, $dbname,
$dboptions)) {
$database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix,
$dboptions);
} else {
throw $e;
}
}
return '';
} catch (dml_exception $ex) {
$stringmanager = get_string_manager();
$errorstring = $ex->errorcode.'oninstall';
$legacystring = $ex->errorcode;
if ($stringmanager->string_exists($errorstring, $ex->module)) {
// By using a different string id from the error code we are separating
exception handling and output.
$returnstring = $stringmanager->get_string($errorstring, $ex->module, $ex->a);
if ($ex->debuginfo) {
$returnstring .= '<br />'.$ex->debuginfo;
}
return $returnstring;
} else if ($stringmanager->string_exists($legacystring, $ex->module)) {
// There are some DML exceptions that may be thrown here as well as during
normal operation.
// If we have a translated message already we still want to serve it here.
// However it is not the preferred way.
$returnstring = $stringmanager->get_string($legacystring, $ex->module, $ex->a);
if ($ex->debuginfo) {
$returnstring .= '<br />'.$ex->debuginfo;
}
return $returnstring;
}
// No specific translation. Deliver a generic error message.
return $stringmanager->get_string('dmlexceptiononinstall', 'error', $ex);
}
}
2
Answers
My problem was two-fold. My client had Wide-Area Firewall (WAF) set incorrectly which prevented communication between Moodle 4.1 and the external PostgreSQL database. Then I figured out they failed to correctly install Postgres 'driver' to the VM.
Can you add these lines to
config.php
then copy and paste the full error message to the question