Deleted config.php (by nextcloud installation script?), panic! 😱

Hello.

I have a small nextcloud 11 (had to edit this, originally I posted I was using nextcloud 10 :sweat_smile:) server running since two weeks for a small office and every was going ok, but it grew to 16 users and started to work a bit slow (server load was over 100% sometimes). So I tried to configure memcached to boost speed.

I was making changes in config.php and apache configuration (I had nextcloud in a separate subdomain using VirtualHost directive and letsencrypt SSL certs) using this guide to configure cache:

https://bayton.org/2016/07/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-apache/

After install and configure APCu and Redis I added the related configuration lines to config.php:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' => 
array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0.0,

But Nextcloud was not loading (only a blank page) so I commented out those lines and checked the /etc/apache2/sites-available/ configuration. I made some changes to clean up the default-ssl.conf because there were duplicate entries and after that… disaster!! :scream:

Next I time I opened the nextcloud web I was facing the default installation page as if it were nextcloud’s first run and [nextcloud_dir]/config/config.php was overwritten with:

<?php
$CONFIG = array (
  'instanceid' => 'oc19s0j0n89i',
);

All my configuration was lost!! :cold_sweat:

Is there a way to recreate the instanceid and the other parameters in config.php to restore the nextcloud installation? (the data/ folder and the database are intact)

If no, how can I reuse the existing database and the data/ folder in a new nextcloud installation? Please, help… :sob:

Thank you very much.

PD: If config.php was deleted by nextcloud installation script (I think the nextcloud instance though it was a first run installation after I made changes in the apache’s default-ssl.conf), please remove that “feature” :cry:
PD2: English is not my first language, please forgive me If my English is not good enough

Maybe you find some standard config.php here in the forum or on docs.nextcloud.com (sorry can’t send mine at the moment, not at home). I guess adding the entries for database type, user, pw and prefix should enable nextcloud to use your “old” instance again. Not sure if the instanceid entry need to be the same again or did actually change.

I don’t know about some script that removes the config.php. Actually on upgrade a backup is done and the old config.php is moved back. In the end that just shows again the importance of backups, your data as well as the nextcloud folder ;).

About memcache:

  • check if the php modules for APCu and redis are installed and enabled.
  • Try to enable first APCu and if it’s running then redis.
  • For redis I i.e. hat the problem that the sock file had the wrong permissions. You can adjust that in redis config.

Later this evening I will in case check back my configs at home and try to help further.

Thank for your reply Michalng.

I have managed to get it working again by making a new config.php using the documentation. I was worried about password salt and instance id, as documentation states the following:

https://docs.nextcloud.com/server/11/admin_manual/configuration_server/config_sample_php_parameters.html#default-parameters

These parameters are configured by the Nextcloud installer, and are required for your Nextcloud server to operate.

'instanceid' => '',

This is a unique identifier for your Nextcloud installation, created automatically by the installer. This example is for documentation only, and you should never use it because it will not work. A valid instanceid is created when you install Nextcloud.

‘instanceid’ => ‘d3c944a9a’,

'passwordsalt' => '',

The salt used to hash all passwords, auto-generated by the Nextcloud installer. (There are also per-user salts.) If you lose this salt you lose all your passwords. This example is for documentation only, and you should never use it.

I did not create a password salt nor an instance id (they were creadted by nexcloud) but all configuration worked and I did not loose any passwords, what is strange. All desktop clients connected almost instantly with the same id and password after I populated config.php with needed data.

Now everything is working again and I have data, database and configuration backup (I already had data backup before the incident :sweat_smile:).

I’ll try to configure cache later (maybe tomorrow) and collabora suite after that. Nextcloud is an amazing piece of software.

Thank you very much.

I’ve used my guide 10s of times, including for my unofficial demo servers and have only seen the blank page you describe when I miss a comma off one of the config entries.

Haven’t seen the config file emptied before though.

Thanks very much for your guide, Jason!!! :grin:

After repairing config.php I have repeated the last step of your guide ensuring not to miss a comma :sweat_smile:. This time it worked without any problem, so probably it was the problem the first time :sweat:

So at last:

  1. Standard Nexcloud installation in ubuntu server 16.04: check!
  2. Force SSL with let’s encrypt certs: check!
  3. APCu and Redis cache integration: check! (thanks Jason!)
  4. Collabora suite integration: check ! (used this guide: https://www.linuxbabe.com/cloud-storage/integrate-collabora-online-server-nextcloud-ubuntu-16-04)
  5. Learnt an important lesson (backup your configuration, not only your data) without too much pain: check! :joy:

About the disappearing of config.php, my guess is that I was tampering with the apache configuration in the sites-available folder and maybe Nextcloud triggered an installation script thinking it was in a new domain when I miss-configured something.

Have a nice day!

1 Like

I very highly doubt it, two separate files all together with no impact on one another. If there’s a config.php in existence with DB info - even broken - NC shouldn’t look to reinstall.