skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. Can you add these lines to config.php then copy and paste the full error message to the question

    // Force a debugging mode regardless the settings in the site administration
    @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
    @ini_set('display_errors', '1');    // NOT FOR PRODUCTION SERVERS!
    $CFG->debug = (E_ALL | E_STRICT);   // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS
    $CFG->debugdisplay = 1;             // NOT FOR PRODUCTION SERVERS!`
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search