0
votes

I have localhost SS 3.4 project, which works fine. Same project on the server works fine with one exception. I can't access the CMS (nor set the page to dev mode) I get server error, which logs as problem with DB connection:

Warning at framework/model/connect/MySQLiConnector.phpline 77: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host ''

and:

Error at framework/model/connect/DBConnector.php line 55: Uncaught SS_DatabaseException: Couldn't connect to MySQL database | Unknown MySQL server host ''

Which is strange because the page uses the DB connection all the time to render content... Any idea how to figure this out?

1
How did you configure DB on the server? Maybe it's missing a proper _ss_environment.php or you just misconfigured db config. - wmk
I used to use _config.php but I switched to _ss_environment.php - it didn't help. Anyway, the page works (the content is displayed) so it's able to connect to the DB, at least for reading purposes. I just had to clone whole local DB to the server to achieve that, cause I couldn't log into the admin. Is there any server specific info in the DB that can prevent the CMS from working? I couldn't find any. - konrad
Here's the original installation problem I encountered: stackoverflow.com/questions/48810203/… and the solution. - konrad
You have a working installation on localhost? The server is pretty the same configuration? Same DB, same PHP-Version etc...? Your code is in a version control (like git) to update it easily on the server? You installed SilverStripe locally using composer? Theoretically you "just" have to make sure, the code on the server is the same, your db credentials are set (use _ss_environment.php for it on a SS3 site, ENV on SS4), copy over assets and put your local DB dump in the live DB. - wmk
You can add the maximum PHP Version to your composer.json, then your local composer won't require anything that doesn't work with PHP5.4. If you have locally 5.6 it'll require newer versions which are written to your composer.lock file. If you run composer install on the server, it "just" installs what you require in the .lock file - without checking any dependencies. - wmk

1 Answers

1
votes

Ok, as wmk suggested it was most probably question of using local composer's lock file to install dependencies on the server despite different local and remote PHP versions (5.4 vs 5.5). After adding platform option to composer.json and reinstalling deps the problem disappeared.

"config": {
    "platform": {
        "php": "5.4.17"
    }
},