Page 1 of 1

config.php for development- and live servers

Posted: Tue Nov 18, 2008 2:21 pm
by Andiministrator
In most cases of development with CMSms, the development takes place on a development server during a stable version runs on the live server. To transfer the whole project from the development- to the live server, you need to change the config.php every time. I did some changes on the config.php to use it in the same version on both, development- and live server.

At the first step I changed the database vars.

Code: Select all

$config['dbms'] = 'mysqli';
if ($_SERVER["SERVER_NAME"]=="LocalHostName" || $_SERVER["SERVER_NAME"]=="www.LocalHostName") {
	$config['db_hostname'] = 'LocalHostName';
	$config['db_username'] = 'LocalUserName';
	$config['db_password'] = 'LocalPassword';
	$config['db_name'] = 'LocalDBName';
	$config['dev'] = true;
} else {
	$config['db_hostname'] = 'RemoteHostName';
	$config['db_username'] = 'RemoteUserName';
	$config['db_password'] = 'RemotePassword';
	$config['db_name'] = 'RemoteDBName';
	$config['dev'] = false;
}
Here I use both database connections. In addition I use the var $config['dev'], to distinguish later on in modules, for example for log files, etc.

Within the next step I get the root url and the root path automatically.

Code: Select all

$config['root_url'] = "http://".$_SERVER["SERVER_NAME"];
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
$config['root_url'] = str_replace('http','https',$config['root_url']);
}

$config['root_path'] = $_SERVER["DOCUMENT_ROOT"];

The last step is to change all fixed pathes to dynamical pathes, for example:

Code: Select all

$config['previews_path'] = $config['root_path']."/tmp/cache";

Find the complete config.php attached.

What do you think, is there anything wrong with that?

Re: config.php for development- and live servers

Posted: Tue Nov 18, 2008 2:44 pm
by nhaack
This sounds really fancy... Will give it a try during the weekend... would really match my situation and make things much easier...

Thanks for sharing.

Best
Nils

Re: config.php for development- and live servers

Posted: Thu May 27, 2010 3:33 pm
by Andiministrator
I added the versions of config.php and .htaccess to a project:
http://dev.cmsmadesimple.org/projects/configms

I use this versions of config.php and .htaccess since 2008 without any problems.

Notice: This versions will activate user-friendly URLs (mod_rewrite).

Re: config.php for development- and live servers

Posted: Mon Aug 23, 2010 5:47 am
by Flyingknight
Thanks for the config.php file. I did not use it to connect to a Live server.. is for connect to a second database.
My problem is that I need to make changes to the login form because I need that the login module uses the data stored in another table in the second database for autentication. This table is different from the users table in the CMS.
How can change the variables in the "login.php"  to match with the "users" table in the second database for autentication? Need this because I have a database full with users info and I can´t ask to the members to register again in the CMS. The another table have a different name too.
Any help will be apreciated.

Thankyou

José

Re: config.php for development- and live servers

Posted: Thu Aug 26, 2010 5:15 am
by Flyingknight
Any idea???

Wow I think that in this forum could find answers, but I was wrong, I'll try to find the answer myself.

Thanks anyway :-[

Re: config.php for development- and live servers

Posted: Sat Sep 04, 2010 1:40 am
by NaN
You're just in the wrong place.
This has nothing to do with a modified config.php (i guess).