Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you treat the deployment of configuration files on different systems in Subversion?

Subversion is a great way to update our web applications on our servers. With a simple svn update all changed files get... well, changed.

Except for the omnipresent configuration files such as config.php which hold the database access configuration, server paths etc. And are therefore different on my local development system and the remote server.

With the update command, a file modified on the server won't get overwritten, but if I change the file locally and commit it, the server gets the wrong configuration file.

But I don't want to set the svn:ignore property either, since the config file belongs to the project.

Is there a Subversion-mechanism which will allow me to easily handle these kind of files? Or is the only way to solve this problem to make a system switch within the config file which will determine the executing system and sets the configuration accordingly?

like image 671
Christian Studer Avatar asked Sep 25 '08 07:09

Christian Studer


2 Answers

Create a template for the file (e.g. config.php-default) and let the user copy the template. She can also do a diff to see what changed between versions to incorporate these changes in the locally deployed version of the file.

like image 93
xmjx Avatar answered Oct 13 '22 01:10

xmjx


You may want to consider the fact that developers won't (And probably shouldn't) have access to the username/passwords for the production machine.

To cope with this, such configuration should be considered to be 'deployment details', rather than overall application configuration. Even when you make this conceptual distinction, you still need to deal with the different deployment environments but, as you seem to be dealing with PHP, I can't comment on specifics for your case.

As Lars mentioned, one possible J2EE solution is to store such details under JNDI, making the exact same application binary deployable on any environment, leaving DBAs/Admins to set the username/password for each machine.

like image 34
belugabob Avatar answered Oct 13 '22 01:10

belugabob