Forum
Moving Perch from local dev to web server staging
Hi,
I've been following the documentation regarding moving a Perch site. (https://docs.grabaperch.com/perch/building/servers/how-do-i-move-a-perch-site/).
I've followed this to the letter, but according to this error, Perch cannot connect to the database?:
Debug Message - Perch Runway 3.0.11
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM pages p LEFT JOIN PERCH_DB_PREFIXpage_routes pr ON p.pageID=pr.pageID LEFT JOIN PERCH_DB_PREFIXsettings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM PERCH_DB_PREFIXpage_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Could not create DB link!
SQLSTATE[HY000] [2002] No such file or directory
Using master page: /templates/pages/errors/404.php
SELECT DISTINCT settingID, settingValue FROM settings WHERE userID=0
Could not create DB link!
SQLSTATE[HY000] [2002] No such file or directory
Could not create DB link!
SQLSTATE[HY000] [2002] No such file or directory
I know the database link to be 'localhost', even checking with my hosting company.
config.dev-theglobelibrarystokesley-org.php (does this need changing to config.staging.theglobelibrarystokesley.org.php?)
<?php
define('PERCH_SITEPATH', 'https://staging.theglobelibrarystokesley.org/');
define('PERCH_SCHEDULE_SECRET', '******************');
define('PERCH_DB_USERNAME', '**********');
define('PERCH_DB_PASSWORD', '**********');
define('PERCH_DB_SERVER', "localhost");
define('PERCH_DB_DATABASE', '**********');
define('PERCH_DB_PREFIX', '**********');
I'm at a bit of loss as to what to try next?
config.php
<?php
switch($_SERVER['SERVER_NAME']) {
case 'dev.theglobelibrarystokesley.org':
include(__DIR__.'/config.dev-theglobelibrarystokesley-org.php');
break;
default:
include('config.production.php');
break;
}
Do these refrences to dev-theglobelibrarystokesley-org need changing to staging.theglobelibrarystokesley.org?
Thanks in advance
Grant, your site path should not be a URL. This should be the file path on your server all the way to your home directory
I didn’t look for additional , I would correct that first and see if that clears things up
Thanks, corrected file path
But this hasn't resolved the issue
I’m pretty sure that’s not the correct site path. This would be the path from the drive on the server to your home directory.
Hmm, so here is a screenshot, in the hope it will help? And why I thought it should be /staging.theglobelibrarystokesley.org/
Thanks again
Hi Grant
I think you want;
define('PERCH_SITEPATH', '/staging.theglobelibrarystokesley.org');
In your config file, this bit;
include('config.production.php');
Should be loading the config file you've made (as you mention calling it 'config.dev-theglobelibrarystokesley-org.php'), so it should be;
include('config.dev-theglobelibrarystokesley-org.php');
I think that should do it... but it is Friday Evening... :)
Wayne
Hello Grant,
Config Files:
Perch gives you the option to have different configs for different environments. So you can have different site paths, database usernames/passwords, etc for each environment without having to edit your config file every time you set up in a new environment.
If you want to use a separate config file for your staging environment, create
config.staging-theglobelibrarystokesley-org.php
, add the appropriate details for the environment in there and add the following to yourconfig.php
:Otherwise Perch will use
config.production.php
when you got tohttps://staging.theglobelibrarystokesley.org
.Site path
PERCH_SITEPATH
is the file system path to the site root. So for your staging config it seems to be/staging.theglobelibrarystokesley.org
like Wayne suggested.Thanks, everyone, now sorted. Sorry I cannot credit more than one person.