When installing PostgreSQL 9.1 through Debian Backports, you'll notice a key difference from the standard installation path. Instead of the traditional /etc/postgresql/9.1/
directory structure, the backports package uses a more modern approach with /etc/postgresql-common/
.
The Debian PostgreSQL maintainers changed the configuration directory structure in newer versions to better handle multiple PostgreSQL instances. The postgresql-common
package now centralizes configuration management. This is actually an improvement, though it might be confusing coming from older installations.
Your main configuration files are now located in:
/etc/postgresql-common/ |-- pg_createcluster.conf |-- pg_ctl.conf |-- postgresql.conf |-- user_clusters
For cluster-specific configurations (equivalent to the old 9.1 directory), check:
/etc/postgresql/<version>/<cluster_name>/
First, verify your PostgreSQL installation is complete and running:
sudo service postgresql status pg_lsclusters
If you need the traditional directory structure, you can create a new cluster:
sudo pg_createcluster 9.1 main --start
This will create the expected /etc/postgresql/9.1/main/
directory structure.
To migrate existing configurations to the new structure:
sudo pg_dropcluster --stop 9.1 main sudo pg_createcluster 9.1 main --start # Then copy your custom configurations from backup
Key files to be aware of in the new structure:
/etc/postgresql-common/postgresql.conf - Global defaults /var/lib/postgresql/9.1/main/ - Data directory /etc/postgresql/9.1/main/ - Cluster-specific configs (after cluster creation)
If your applications expect the old configuration path, you might need to update connection strings or configuration references. For example, in PHP:
// Old way $host = '/var/run/postgresql/.s.PGSQL.5432'; // New recommended way $host = 'localhost'; $port = '5432';
To verify everything is working correctly:
sudo -u postgres psql -c "SELECT version();" sudo netstat -tulnp | grep postgres
If after these steps you still can't locate your configuration files or the service won't start, check:
sudo apt-get install --reinstall postgresql-9.1 postgresql-client-9.1 postgresql-common sudo dpkg-reconfigure postgresql-common
If problems persist, consider filing a bug report with:
reportbug postgresql-9.1
When installing PostgreSQL 9.1 from backports on Debian Squeeze, you might notice the configuration files aren't where you'd normally expect them. Instead of /etc/postgresql/9.1/main
, you only find /etc/postgresql-common
. This is actually expected behavior in Debian's packaging.
# Expected traditional structure: /etc/postgresql/ └── 9.1 └── main ├── postgresql.conf ├── pg_hba.conf └── pg_ident.conf # Actual structure in this case: /etc/postgresql-common/ ├── pg_upgradecluster.d ├── postgresql.conf └── user_clusters
Debian's postgresql-common package introduced a new multi-version clustering system. The traditional directory structure was replaced with a more flexible approach:
- Configuration files are now managed through symlinks
- Multiple PostgreSQL versions can coexist more easily
- Cluster management is handled through
pg_createcluster
andpg_ctlcluster
Even without the traditional directory structure, your configuration files still exist. You can locate them with:
# List all clusters pg_lsclusters # Expected output: Ver Cluster Port Status Owner Data directory Log file 9.1 main 5432 online postgres /var/lib/postgresql/9.1/main /var/log/postgresql/postgresql-9.1-main.log
The actual configuration files will be in the data directory under postgresql.conf
:
# View the main configuration file sudo nano /var/lib/postgresql/9.1/main/postgresql.conf
If you prefer the traditional layout, you can create it manually:
sudo mkdir -p /etc/postgresql/9.1/main sudo cp /var/lib/postgresql/9.1/main/postgresql.conf /etc/postgresql/9.1/main/ sudo cp /var/lib/postgresql/9.1/main/pg_hba.conf /etc/postgresql/9.1/main/ sudo chown -R postgres:postgres /etc/postgresql # Then edit the data_directory parameter in postgresql.conf data_directory = '/var/lib/postgresql/9.1/main'
The newer approach actually provides more flexibility. Key commands to know:
# Create a new cluster sudo pg_createcluster 9.1 mycluster --start # Start/stop a cluster sudo pg_ctlcluster 9.1 main start sudo pg_ctlcluster 9.1 main stop # Upgrade a cluster sudo pg_upgradecluster 9.1 main
If services aren't starting properly, check:
# View PostgreSQL logs tail -f /var/log/postgresql/postgresql-9.1-main.log # Check service status sudo service postgresql status # Verify cluster is registered sudo pg_lsclusters
Remember that in this packaging approach, the init script (/etc/init.d/postgresql
) manages all clusters collectively rather than individually.