There's a better way. Use _ss_environment.php to your advantage.
In your SilverStripe 2.4 base folder, create a file called _ss_environment.php and put the following line in it:
define('BASE_PATH', rtrim(dirname(dirname($_SERVER['SCRIPT_FILENAME'])), DIRECTORY_SEPARATOR));
Of course you are free to also add DB information that all your installations share, as described on the doc page above.
Then simply put the following line into mysite/config.php
That's all. Works a charm here... here's how my file-structure of a typical site looks like:
BaseInstall2.4.1 (silverstripe codebase)
+- _ss_environment.php (as described above)
SomeSite (all website folders are structured like this)
+- sapphire (symlinked to BaseInstall2.4.1/sapphire)
+- cms (symlinked to BaseInstall2.4.1/cms)
+- googlesitemaps (symlinked to BaseInstall2.4.1/googlesitemaps)
+- dataobject_manager (symlinked to BaseInstall2.4.1/dataobject_manager)
+- swfupload (symlinked to BaseInstall2.4.1/swfupload)
+- assets own asset folder for each site
+- mysite own mysite folder for each site
+- _config.php as described above
So all websites are structured like SomeSite and have only a custom assets and mysite folder, but otherwise share the same codebase.