Score:0

logging working on local site but not remote site

in flag

I recently migrated from Drupal 8 to 9. Works ok on my local (MAMP on Mac), but not on the remote (AWS Lightsail). Local has PHP 7.4.12, Remote has PHP 7.4.2.

I put the entire codebase in git, and pulled it to my remote server. I created settings.php for the remote host, set trusted_host_patterns, sites.php, .htaccess. I had a similar setup for Drupal 8 on the remote, which worked flawlessly.

Here's what I see in my apache error log when I try to hit the home page:

  1. AH01071: Got error 'PHP message: Drupal\\Core\\Database\\DatabaseAccessDeniedException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

I did set the correct mysql user/pwd in settings.php and verified it was reading it by changing the user, and could see the new user name in the errors.

  1. AH01071: Got error 'PHP message: Error: Interface 'Psr\\Log\\LoggerInterface' not found in /home/bitnami/repo/www/web/core/modules/dblog/src/Logger/DbLog.php on line 16

I do have "psr/log": "^1.1" in my composer.json.

What I'm not getting is why things work on my local, but not my remote.

jbarrio avatar
cn flag
For the first question, you need to configure the settings.local.php to point to the real database host, user and password. I doubt in Amazon you can use user root to point to localhost, so be sure you set the right values. Regarding second question, having psr/log in your composer doesn't mean it was installed. Did you run 'composer install' to be sure it was deployed? Did you get any error message?
No Sssweat avatar
ua flag
To make sure the db connection is indeed being made. You could delete the settings.php file and let Drupal recreate it when you try to view the site. You'll get the instalation wizard as if you were doing a fresh install except since the DB is not empty, it will not install Drupal to the DB.
No Sssweat avatar
ua flag
Also, wouldn't hurt to run `composer install --no-interaction --prefer-dist --optimize-autoloader`
pglatz avatar
in flag
Thanks for the suggestions.I do have a different Lightsail server that's configured similarly, but is running a Drupal 7 site; works fine with user=root and host=localhost. I'm using the LAMP/PHP stack, and installed mysql manually. Yes, using root as username isn't a great idea, but this is a temporary dev server with little value to the data. I did run composer install with the args you recommended, made no difference.
pglatz avatar
in flag
Still getting the PSR error: `Error: Interface 'Psr\\Log\\LoggerInterface' not found in /home/bitnami/repo/www/web/core/modules/dblog/src/Logger/DbLog.php on line 16 #0 /home/bitnami/repo/www/vendor/composer/ClassLoader.php(480): include()\n#1 /home/bitnami/repo/www/vendor/composer/ClassLoader.php(346)`
Score:1
in flag

Found the problems - ever want to kick yourself for overlooking the obvious - the reason it wasn't finding psr/log is that when I restored it from git, I didn't realize it was a submodule. After cloning the repo, I had to: Issue a git submodule init command. Issue a git submodule update command.

And the login error I was having was due to a network error on my end, it wasn't pointing to the correct server.

Glad I got this solved, and great appreciate the suggestions.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.