backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Exception: The configuration directory in settings.php is specified as 'files/config_[some-random-CMI-ID-here]/active', but this directory is either empty or missing crucial files. #264

Closed klonos closed 3 years ago

klonos commented 10 years ago

Every time I try to install Backdrop, right after the stage of enabling modules (progress bar), I am greeted with this error page:

Error The website encountered an unexpected error. Please try again later.

Exception: The configuration directory in settings.php is specified as
'files/config_[some-random-CMI-ID-here]/active', but this directory is either empty or
missing crucial files. Check that the $config_directories variable is correct in settings.php. in
_backdrop_bootstrap_configuration() (line 2470 of /var/www/backdrop/core/includes/bootstrap.inc).
quicksketch commented 10 years ago

Hi @klonos :) thanks for filing a new issue. Could you describe the environment on which you're trying to install Backdrop? e.g. a Mac with MAMP, or homebrew? Linux distro, Windows + WAMP, etc? This is a pretty important issue, since who knows how many other people haven't even been able to install Backdrop. :(

One more thing to check: Does a "files" directory get created for you in the root directory of your Backdrop install? And inside of it, is there the "config_[hash]" directory? The installer is supposed to check that the files directory either exists or can be created before the installer even starts, but our developer base is pretty small so there are probably circumstances in which we haven't tested.

Really appreciate any information you can provide, I'll try to reproduce and get this worked out.

klonos commented 10 years ago

Sorry, you are right. I'm on Ubuntu 14.04 x64 with the latest stable packages of apache2/php/mariadb10. I have tried this in several similar boxes that already run Drupal 7/8 without an issue.

Hope that makes it more clear. If you need more clarifications or you have any pointers as to what I could possibly do to troubleshoot, please let me know.

PS: ...btw I always got backdrop through the "download zip" link on github.

quicksketch commented 10 years ago

Hm, okay I'll have to spin up a VM. I'll try to test this tomorrow. Does the "files" directory get created in the root of your installation? I think this is likely to be a permissions issue, where Backdrop can't create or potentially read out of the files directory.

klonos commented 10 years ago

I create the /files directory before starting the installation and make sure it has the correct permissions (chown www-data). So after installation (and the error page) there are the following files/directories:

/var/www/backdrop/files/config_a1614e81308b9e6b86be181ef0914335/active/README.txt /var/www/backdrop/files/config_a1614e81308b9e6b86be181ef0914335/active/system.performance.json /var/www/backdrop/files/config_a1614e81308b9e6b86be181ef0914335/staging/README.txt /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/admin_menu.settings.json /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/image.styles.large.json /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/image.styles.medium.json /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/image.styles.thumbnail.json /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/README.txt /var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/staging/README.txt /var/www/backdrop/files/styles [empty]

quicksketch commented 10 years ago

Ah, wow fascinating. Looks like somehow during the installer it's getting two different hashes for the config directory. In the mean time, if you just move that system.performance.json file into the other directory (/var/www/backdrop/files/config_faf90df4e5aa9cf4e874ddd215172e98/active/), then things should work. Thanks again for the report, this sounds pretty critical.

dgtlife commented 10 years ago

I just installed Backdrop and got the same error at the very end. I also ended up with two config directories. Once I moved the system.performance.json from the duplicate directory to the "official" config directory, like you suggested, and deleted the duplicate directory, then there are no subsequent errors, and everything is fine after that.

quicksketch commented 10 years ago

I've been looking through the install process and I haven't been able to pin this down yet. @dgtlife, thanks for confirming the problem. Are you also using Ubuntu or a Linux distro?

quicksketch commented 10 years ago

Well I'm a little bit stumped. I installed Ubuntu 12.10, PHP 5.4.6, MySQL 5.5.27, and ran through the installer as provided by the 1.x.zip file from Github. I had to chmod 777 the settings.php file temporarily and chown www-data the files directory, then ran the installer. I did not end up with the duplicate config directories. So I haven't been able to reproduce this issue yet. Any other information you guys can provide that might reproduce this problem would be appreciated.

dgtlife commented 10 years ago

@quicksketch, here are my environmental details: Ubuntu 14.04 LTS x86_64 on a physical server Nginx 1.4.6 PHP/PHP-FPM 5.5.9 MariaDB 10.0.12 Backdrop 1.x (from the backdropcms.org home page ... which pulls from github)

I made sure settings.php was writable (chmod 664) before running the install, but I didn't create the files directory before hand since it wasn't called out in the install instructions, and I assumed pre-creation wasn't necessary. However, during the install the files directory gets properly created and chowned. I will do another install later with a pre-created files directory and see how that goes.

dgtlife commented 10 years ago

I just did a second install with the same context as above. This time I created the files directory (and made it rwx by www-data) before I started the installation. However, I still got the same error and two config_ directories. The "unofficial" config_ directory contained the system.performance.json file in the active subdirectory along with a README.txt. And once this file is moved to the official config_ directory, everybody's happy.

quicksketch commented 10 years ago

Thanks @dgtlife, very helpful. I was using an old install of Ubuntu because virtualbox.org doesn't have 14.x images yet, but I'll give this another shot.

dgtlife commented 10 years ago

I can retest if you need me to, once you've determined the root cause.

oadaeh commented 10 years ago

@klonos and @dgtlife when going through the install process, did you get a situation where on the Database configuration page you had to click Save and continue twice? IOW, did you click the button and nothing seemed to happen, and then click it again or refresh the page and the installation continued on?

That happened to me the only time I was able to successfully reproduce this. The same thing has happened to me many times with Drupal 7, but there isn't a config directory being created and the installation completes normally, and it's intermittent, so it's hard to reproduce, and so no one has reported it as a bug.

dgtlife commented 10 years ago

@oadaeh No, just the one click. And I've never seen this with Drupal 7 ... yet.

vrteach commented 10 years ago

I can confirm seeing this same problem on Ubuntu 14.04 32bit physical server, new install, running apache & mariadb. After going through backdrop install (including making the ./files directory and doing the user & permissions stuff) I have the exception error as listed in this issue title, and I have two config directories: config_814544ecf2f9aa2232e9d8e73f6ded53 config_a1614e81308b9e6b86be181ef0914335

The second one contains the system.performance.json file. After copying that over to the "config_8.." directory I get the "congratulations you've installed" page.

The database configuration page only required one click-and-save.

klonos commented 10 years ago

Ok guys, sorry for the late reply. I'll try to answer as many of the questions...

I have no access to the Ubuntu 14.04 x64 box I was using, so I cannot confirm that moving the system.performance.json to the "official" directory solves the issue. I am sure it does, but cannot confirm right now. I will do so as soon as I can.

I can confirm that it took only one click on the db configuration step.

I have just installed this on a Win8 x64 box and everything went smoothly (installation finished without any errors / only one config_ folder under the files directory).

The only thing I need to point is that I've noticed that dgtlife an I have similar environments. That is Ubuntu 14.04 x64 with MariaDB 10.x.

Hope all this helps. Let me know if there's anything else you need to troubleshoot and as I said, as soon as I have access to the Ubuntu box with the actual issue, I'll try and post back.

PS: ...as I've explained in the issue summary, I've been having this issue since forever (= since I first started testing backdrop back in Jan/Feb 2014). I never actually filed an issue because I thought that it was an early stage of development, but now it is so close to the intended 1.0.0 release date.

klonos commented 10 years ago

...ok back again testing on the Ubuntu 14.04 x64 box. Just to confirm that copying the system.performance.json to the other folder solves the problem.

i-amdroid commented 9 years ago

I got this error on the last step, when try to install backdrop-1.0.0 in multisite.

The website encountered an unexpected error. Please try again later.
Error messageException: The configuration directory in settings.php is specified as 'files/config_9cc1679c2db04eebc28b082df49ee63c/active', but this directory is either empty or missing crucial files. Check that the $config_directories variable is correct in settings.php. in _backdrop_bootstrap_configuration() (line 2668 of /var/www/backdrop/core/includes/bootstrap.inc).

I had only one config_* directory, same as specified in settings.php. And there is no system.performance.json in it.

Ubuntu 14.04.1, php 5.5.9, apache 2.4.7, mysql 5.5.40

Single site installation went fine.

quicksketch commented 9 years ago

Hi @paulanders! If you're using Backdrop in multisite, each settings.php file needs to point to a different config directory. I'd recommend updating settings.php to hard-code the config directories before you run the installer.

Because keeping track of a bunch of random-hash config directories is going to be difficult, you could name each config directory based on it's site name. For security, you should keep these directories outside of the web root. e.g.

$config_directories['active'] = '../config/site_name1/active';
$config_directories['staging'] = '../config/site_name1/active';

and on the other site:

$config_directories['active'] = '../config/site_name2/active';
$config_directories['staging'] = '../config/site_name2/active';

You may also be the first person to try Backdrop in a multisite installation, Thanks for letting us know about this potential problem.

quicksketch commented 9 years ago

The original report here filed by @klonos was solved in https://github.com/backdrop/backdrop-issues/issues/470. We now specifically hard-code the config directories to prevent multiple directories from being created. @paulanders if multisite installations look like an ongoing problem, let's make a new issue to track that and link it up to the meta of install issues at https://github.com/backdrop/backdrop-issues/issues/531

iconoclasta-digital commented 5 years ago

I am sorry to necropost here, but, it's January 5th, 2019 and I am getting this error, but on a FreeBSD 12.0 box.

I managed to install 1.) FreeBSD, 2.) Apache 2.4, 3.) MySQL Server 8.0 and & 4.) PHP 7.2.

I made sure that the backdrop database was properly created, with its proper user and I made sure that I can login into MySQL and access the database.

I proceeded to download Backdrop 1.13.3 (version to this date), unzipped the file in /usr/local/www/apache24/data and moved the backdrop files unzipped there to the data folder (which is the root folder of any website in Apache, as most might know).

I proceed to change the ownership of all the files in the 'data' folder in order to avoid permission problems, by executing 'chown -R www:www *'.

The 'files' directory is already created in the root site, and it's not empty. It has two (2) files: .htaccess & README.md.

When opening a web browser (Chromium, in my case), and point to http://localhost, I get the nasty error that has been discussed here since 4 years ago.

For some some reason, no config_* hashed directory is created. I'm stuck here. I didn't want to open a new issue since this issue is recurring, but under FreeBSD 12.0.

Any help would be appreciated.

docwilmot commented 5 years ago

@iconoclasta-digital when you attempted this, was there a new settings.php file or did that file already have a line that said $config_directories['active'] = './files/config_SOMETHING/active';?

iconoclasta-digital commented 5 years ago

@docwilmot Yes, there was a new settings.php file already created. I had to modify the $database = 'mysql://my-backdrop-user:password@localhost/backdrop_database'; in order to reflect the proper user and database that I am intending to use for backdrop. Of course, the my-backdrop-user and backdrop_database in the present code in the settings.php file are for sampling reasons. But, I already made sure that the proper backdrop user account for MySQL and the database are both accessible to the system and working.

Also, this settings.php file DID NOT have a hashed database attached to the $config_directories.

This is the code that is actually inside my settings.php, which already was created the moment I unzipped the backdrop.zip installer, downloaded from github.

$config_directories['active'] = 'files/config_' , md5($database) , '/active'; $config_directories['staging'] = 'files/config_' , md5($database) , '/staging';

As you can see, the settings file is fine, but there is no hashing of the database and posterior adding as a configuration string to the settings.php file.

Notice: PHP 7.2 has stopped supporting the mcrypt module, and instead is encouraging developers to use the sodium plugin for hashing and cryptographic reasons.

I don't know if the reason that the system is not creating the hash and then adding it to the configuration string is because of this.

Thanks for reading.

docwilmot commented 5 years ago

I had to modify the $database = 'mysql://my-backdrop-user:password@localhost/backdrop_database';

That the problem. If $database isn't empty, Backdrop assumes this is an existing installation, and assumes there is a config directory named 'files/config_' , md5($database) , '/active', or in other words 'files/config_' , md5(mysql://my-backdrop-user:password@localhost/backdrop_database) , '/active', which doesnt exist. Backdrop also will not create a config directory, because, it assumes this is an existing installation.

Did you plan to use an existing database with existing tables? Or were you trying to avoid using the installer?

docwilmot commented 5 years ago

I suspect though that other people may expect to be able to just insert their database credentials in settings.php just like @iconoclasta-digital did. Maybe we should modify the install process to ask if the user wants Backdrop to create the config directory for them, rather than just crashing. @quicksketch @herbdool @serundeputy what do you think? We don't want a bad impression at the install phase for potential new users.

iconoclasta-digital commented 5 years ago

@docwilmot Are you telling me that I shouldn't follow any of the online tutorials about how to setup for the first time a backdrop installation, thus NOT to configure 1.) an empty database of my naming preference, 2.) a user for database and 3.) not to touch the settings.php file and attempt an installation in that way?

I'm quite puzzled here, since most tutorials that try to explain how to setup a new backdrop installation suggests all the contrary, that is, to create a database and a user for that database and then to modify the settings.php file in order to reflect those changes.

Could you kindly clarify that matter. And thank you so much for taking your time.

docwilmot commented 5 years ago

that would be unfortunate. can you post links to those tutorials please?

klonos commented 5 years ago

@iconoclasta-digital friendly ping. I am also curious as to which tutorials mention that way of installation.

iconoclasta-digital commented 5 years ago

@docwilmot & @klonos I'm so sorry for my late reply. I've been busy with IRL stuff. When I google: Install Backdrop Freebsd, the first hits that I get are: https://www.vultr.com/docs/how-to-install-backdrop-cms-on-a-freebsd-11-famp-vps & https://www.alibabacloud.com/blog/how-to-install-backdrop-cms-on-famp-freebsd-111_585765. The other hits are basically a verbatim copy of these two. So, as you can see, they suggest to modify the settings.php manually.

drupol commented 5 years ago

I also tried to install using the docker image, I have the same issue.

I posted the same issue here as well: https://github.com/backdrop-ops/backdrop-docker/issues/20

auxiliaryjoel commented 5 years ago

I have backdrop CMS running correctly on localhost (mac, with MAMP) when I git clone to my live server (shared cPanel hosting) I receive this same error. what do I have to change in the settings.php folder on my live server to allow the site to load?

auxiliaryjoel commented 5 years ago

UPDATE: I noticed my settings.php was referencing a directory that git did not push to cpanel. I realised the default .gitignore file has /files directory set to be ignored (where the config directory is stored), so I removed the /files directory from the .gitignore file and then added files directory to git, pushed it to github, and then git pulled it on my cpanel.

Now, when I load my main site url: mydomain.com/mydirectory I no longer get the config warning, but instead I just get the stock standard drupal/backdrop error of: The website encountered an unexpected error. Please try again later.

What next? I am going to check if there is any trusted_host details in settings.php that I need to change.....

UPDATE 2: I cannot find any "trusted_host_patterns" data inside my settings.php file so I guess that is not the problem?

What other settings in my settings.php file would be OK on my localhost, but not OK on my Live/cPanel server?

stpaultim commented 5 years ago

@auxiliaryjoel

1) As you have seen. Your config files are defined in your settings.php file and you must have directories that match that path and location. Make sure that the permissions are set correctly.

2) If you trying to go through the install process. Your active config directory must be empty. You can put existing config in your staging directly and sync it later, but if you are working with fresh database, then the active config directory must be empty.

3) On a related note, if you have moved an active database into the site, then you should be sure to put the corresponding config files in the active directory. If the database and config directories are out of sync, you will run into problems.

If you have checked all three of these things, let me know.

auxiliaryjoel commented 5 years ago

Hi @stpaultim I can confirm the directories are correct, but what should the permissions be and are we talking about overall permission for the main config folder or particular files inside it?

auxiliaryjoel commented 5 years ago

Not sure what #3 means? I have not added any sql manually to the cpanel server. I setup a database in my localhost MAMP phpmyadmin, but I have not added any on the cpanel server. do I need to make one on the cpanel server. and if so should I do it before or after I git clone the backdrop site to the cpanel?

auxiliaryjoel commented 5 years ago

@auxiliaryjoel

1) As you have seen. Your config files are defined in your settings.php file and you must have directories that match that path and location. Make sure that the permissions are set correctly.

2) If you trying to go through the install process. Your active config directory must be empty. You can put existing config in your staging directly and sync it later, but if you are working with fresh database, then the active config directory must be empty.

3) On a related note, if you have moved an active database into the site, then you should be sure to put the corresponding config files in the active directory. If the database and config directories are out of sync, you will run into problems.

If you have checked all three of these things, let me know.

I looked in cpanel files/config.../ and the active directory had heaps of files in it. so I deleted them all and refreshed the main url. This has now brought back the old error again: Exception: The configuration directory in settings.php is specified as './files/config_d288997df7e59ac84f89c0935818f46d/active', but this directory is either empty or missing crucial files. Check that the $config_directories variable is correct in settings.php. in _backdrop_bootstrap_configuration() (line 2998 of /home/coastto1/public_html/dylan-bdrop/core/includes/bootstrap.inc).

auxiliaryjoel commented 5 years ago

@auxiliaryjoel

1) As you have seen. Your config files are defined in your settings.php file and you must have directories that match that path and location. Make sure that the permissions are set correctly.

2) If you trying to go through the install process. Your active config directory must be empty. You can put existing config in your staging directly and sync it later, but if you are working with fresh database, then the active config directory must be empty.

3) On a related note, if you have moved an active database into the site, then you should be sure to put the corresponding config files in the active directory. If the database and config directories are out of sync, you will run into problems.

If you have checked all three of these things, let me know.

I had no database on cpanel, so I just made one. I noticed my settings.php references the database but it is referencing the localhost, like this: $database = 'mysql://(databaseuser):(password)@localhost/(databasename)'; $database_prefix = ''; The database I created on my cpanel server has same name, user and password. how do I rewrite the above 2 lines of code to be correct for the cpanel server?

stpaultim commented 5 years ago

There are several ways to move a site. But, these general rules might help you figure out your specific problem.

  1. The code
  2. The database
  3. The files
  4. The config (although you maybe managing them in the files directory)

When I set up a new site, I usually MOVE all of these item at once. Recognizing that the site will not work at all until all four are in place.

However, sometimes, I do this:

1) Move the code 2) Create an empty database 3) Run through the install process (and connect to the empty database) to make sure the site is working (as simple vanilla backdrop site)

The first option is probably better, but there might be time when the second is easier.

auxiliaryjoel commented 5 years ago

I moved all files in backdrop localhost directory to my cpanel via git repository. when I loaded the main Backdrop URL on live server, it initially bought up the install window, but after clicking install it went to this:

Backdrop already installed

To start over, you must empty your existing database.
To install to a different database, edit the settings.php file located in the root folder of this site.
To upgrade an existing installation, proceed to the update script.
View your existing site.

the first time I saw this, I realised FILE directory was missing. so I git added/pushed/pulled it. and then refreshed the URL, which gave me the error that this issue is about. But now I have clicked back arrow on my web browser to get back to this option:

To upgrade an existing installation, proceed to the update script.

I clicked the UPDATE SCRIPT option, out of curiosity and now the error is:

PDOException: SQLSTATE[28000] [1045] Access denied for user 'backgropdpbuser'@'localhost' (using password: YES) in backdrop_get_installed_schema_version() (line 170 of /home/coastto1/public_html/dylan-bdrop/core/includes/install.inc).

Now its possible I should not be using the update script, but regardless of that, it seems that my cpanel Database User does not have correct permissions. What do I do to fix that?

stpaultim commented 5 years ago

Make sure you have done all of these things. Site will not work unless you do them all. I have not seen you mention migrating the database yet. Confirm you have done all of these and then report back error messages. If you do this process, you should never need to run update script or installer.

auxiliaryjoel commented 5 years ago

I just exported my database from localhost mamp, and imported it into my live server cpanel. I have re-loaded the config files into the active directory (I took them out earlier during troubleshooting). I've refreshed my main URL and I get the generic error: The website encountered an unexpected error. Please try again later.

So I guess this is permissions or something? What permissions on what files or folders should I be checking?

auxiliaryjoel commented 5 years ago

I checked the config directories and they are named correctly as per settings.php SQL: in my settings.php here is how the Database is referenced:

$database = 'mysql://backgropdpbuser:(password)@localhost/backdropdb'; $database_prefix = '';

I rang my hoster and they suggested the Database name is not needed so I tried this:

$database = 'mysql://backgropdpbuser:(password)@localhost'; $database_prefix = '';

But that just loaded a blank white page (no error just empty page) The hoster also suggested I reference the prefix specifically so I also tried this:

$database = 'mysql://backgropdpbuser:(password)@localhost'; $databaseprefix = 'coastto1';

and this:

$database = 'mysql://backgropdpbuser:(password)@localhost/backdropdb'; $databaseprefix = 'coastto1';

(Note above 2 both specify prefix, first one does not name database and the 2nd one does) But both times I had no luck either. Now I reverted back to this:

$database = 'mysql://backgropdpbuser:(password)@localhost/backdropdb'; $database_prefix = '';

and I am left with this error:

(main logo) Error: The website encountered an unexpected error. Please try again later.

stpaultim commented 5 years ago

It doesn't make much sense to me that you would not need the name of the database.

This might be a situation in which it makes sense to:

Good luck. I'm going offline soon.

auxiliaryjoel commented 5 years ago

what would a fresh settings.php file look like? the only one I have is the localhost one which already references databases and config files. When you say "fresh settings.php" file - do you mean to just delete the references to Database and Config directory?

stpaultim commented 5 years ago

To get a fresh settings.php simply find default.settings.php (from a fresh Backdrop download) and rename it settings.php.

auxiliaryjoel commented 5 years ago

I found a solution that worked for me. I changed this:

$database = 'mysql://backgropdpbuser:(password)@localhost/backdropdb';

to this:

$databases['default']['default'] = array ( 'database' => 'coastto1_backdropdb', 'username' => 'coastto1_backgropdpbuser', 'password' => '(password)', 'prefix' => '', 'host' => 'localhost', 'port' => '3306', 'driver' => 'mysql', );

and now the site is working correctly

stpaultim commented 5 years ago

Congratulations!

klonos commented 5 years ago

@auxiliaryjoel wondering if your password had any special characters (other than letters and numbers that is). If so, can you please post which ones?

auxiliaryjoel commented 5 years ago

@auxiliaryjoel wondering if your password had any special characters (other than letters and numbers that is). If so, can you please post which ones?

Hi @klonos no I just double checked and there is only letters and numbers

klonos commented 5 years ago

Thanks for taking the time to reply @auxiliaryjoel. If you had to sum things up, what would you say the problem turned out to be? Was it only the format of the database connection details?

FTR: Backdrop supports both formats, but for different purposes (see https://api.backdropcms.org/database-configuration).

I noticed that you mentioned that $database = '...'; did not work for you, but I also see that you are using a db prefix. In that case, perhaps you should have specified the prefix. Something like this perhaps:

$database = 'mysql://coastto1_backgropdpbuser:(password)@localhost/coastto1_backdropdb';
$database_prefix = 'coastto1_';