I'm building PostgreSQL(version 9.3.1) from source code in Ubuntu. I'd like to create several builds of Postgres, like pg1, pg2, etc. How can I do it? Thanks in advance.
Which os and version are you using?
Even though I disagree with you on doing this, my approach would be to build them and keep the destination directory different from one build to the other. Something like
/usr/local/postgresl-9.3, /usr/local/postgresql-8.4 etc. This would avoid overwriting executable files such as psql or initdb for example. In order to better control the installation then use a package manager to build the packages for your system and install them. (For example in slackware we use the
createpkg command to bundle up a package so that it can then be handled by the package manager
Then for every version you would have to issue an
initdb on a different base directory and manually start postgres taking care of using the relative `pg_ctl' command.
Be sure to use the full path to the various executable files of the different database versions.
Another issue you will have to take care of is to modify
postgresql.conf of every instance that you are running in order to make them listen on different ports, should you required to run every database instance simultaneously. Otherwise you can run them one at a time on the default port
If you use the --prefix=PREFIX option while building from source, won't that help? You would also need to look at other options such as --with-pgport=NUMBER to ensure that you don't end up forgetting to change the port in postgresql.conf. Please have a look at http://www.postgresql.org/docs/current/static/install-procedure.html for other options you might want to change.