NextCloud: Heroku: Install: Update Config File with Database Credentials

From Gratiel's Wiki
Revision as of 15:49, 2 September 2019 by Ewanchic (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Obtain the Updated Config File

Now that the Nextcloud setup has began steps to initialize the database, it is time to gather new information provided by the config. Begin by logging into the Heroku app.

heroku ps:exec --app infinite-lowlands-88888
Establishing credentials... done
Connecting to web.1 on ⬢ infinite-lowlands-88888... 

Navigate to the config section and display a copy of the config file:

cd server/config
cat config.php
<?php
$CONFIG = array (
  'instanceid' => 'ocklnegqyxwr',
  'passwordsalt' => 'MA+YVjYA73HvHVBi+qBnHwPv0ghVeD',
  'secret' => 'KuSrqOkikCjpq/tJHw+meG/kW3cHbaTYoO/1/TjizxthxjUL',
  'trusted_domains' =>

  array (
    0 => 'infinite-lowlands-88888.herokuapp.com',
  ),
  'datadirectory' => '/app/server/data',
  'dbtype' => 'pgsql',
  'version' => '15.0.7.0',
  'overwrite.cli.url' => 'http://infinite-lowlands-88888.herokuapp.com',
  'dbname' => 'daph5kfg77n38n',
  'dbhost' => 'ec2-107-20-155-148.compute-1.amazonaws.com',
  'dbport' => ,
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xowkanpiyumlbq',
  'dbpassword' => 'e471e13d2122edca41c6c248b543954933baa4c2bb5aa685735329835e7bf969',
);

This step not only establishes the database and site credentials (which we could have added manually), but it sets up the: username & password, password salt, and secretkey which all are encoded into the database.

Update Config File in Development

We are going to need to save these values and enter them into Heroku's Config Vars.

Now we need to modify the config.php in your desktop version to accept environment variables. Change your config file to read: Note: Be sure to replace the variables that work for your instance of NextCloud!

<?php
$CONFIG = array (
  'instanceid' => 'ocklnegqyxwr',
  'passwordsalt' => getenv('PASSWORD_SALT'),
  'secret' => getenv('SECRET'),
  'trusted_domains' => 

  array (
    0 => 'infinite-lowlands-88888.herokuapp.com',
  ),
  'datadirectory' => getenv('DATA_DIRECTORY'),
  'dbtype' => 'pgsql',
  'version' => '15.0.7.0',
  'overwrite.cli.url' => 'http://infinite-lowlands-88888.herokuapp.com',
  'dbname' => getenv('DB_NAME'),
  'dbhost' => getenv('DB_HOST'),
  'dbport' => ,
  'dbtableprefix' => 'oc_',
  'dbuser' => getenv('DB_USER'),
  'dbpassword' => getenv('DB_PASSWORD'),
);


Go ahead and update the config.php on your local git repo to match this. Save and commit.

git add .
git commit -m "Updated config.php. Includes DB credentials, trusted site credentials, passwordsalt & secretkey. All important values are being replaced by Environment Variables."

Return