# Fedora 17 not so easy PostgreSQL configuration

> I don&#x27;t usually post rants here, but this one might be actually helpful to others, so let&#x27;s make an exception. It will be related to installing PostgreSQL from…

I don't usually post rants here, but this one might be actually helpful to others, so let's make an exception. It will be related to installing PostgreSQL from distro-specific packages. I usually prefer setting PostgreSQL from sources, unlike the majority of users; nevertheless, I'm familiar with how popular distros, like Debian or Fedora, manage their PostgreSQL layouts. Or so I thought until today. 

My task was simple: install PostgreSQL instance for testing on a fresh Linux box, use a non-standard port. The catch: the box was running a relatively new Fedora 17. 

Normally, I run a single database instance per each host, so I find Fedora's PostgreSQL layout much more straightforward then Debian's: all configuration files are stored in $PGDATA ( _/var/lib/pgsql/data_ by default), just like in a source-based installation. Everything you need to change should be there. 

I launched vim on _/var/lib/psql/data/postgresql.conf_ , uncommented **listen_address** , setting it to '*' to allow the server to listen on TCP sockets and modified the **port** line to 5552. Afterwards, I did 
    
    
    service postgresql restart

Nothing happened. By examining 
    
    
    ps ax|grep postgresql

I confirmed my guess that the port number is embedded into the PostgreSQL command-line. So, let's check _/etc/rc.d/init.d/postgresql.service_. 

Alas, there were no postgresql related files there. At that moment I started to have my suspicions. I did 
    
    
    find / -name 'postgresql*'

and found a bunch of files called postgresql.service. The most promising of them was _/usr/lib/systemd/system/postgresql.service_ , so I pointed my editor there. The file indeed contained the setting for PostgreSQL port, along with a warning, stating the changes would be overwritten during package. There was a suggestion to create _/etc/systemd/system/postgresql.service_ and include the current postgresql.service there before adding a line that changes PGPORT. 

I did the suggestion above and issued service postgresql restart once again. My custom _postgresql.service_ looked like this: 
    
    
    .include /usr/lib/systemd/system/postgresql.service
    [Service]
    Environment=PGPORT=5552
    

Guess what - nothing had changed. Before giving up and going to google for answers I had tried on last thing - changing the _/usr/lib/systemd/system/postgresql.service_ directly, despite the warning, and doing service restart. Amusingly, nothing changed even then, but I got another warning suggesting to run systemctl --system daemon-reload. 

Finally, I reverted my _/usr/lib/systemd/system/postgresql.service_ changes, did 
    
    
    systemctl --system daemon-reload

restarted postgresql service one last time and the changes in _/etc/systemd/system/postgresql.service_ finally came into effect. Ran netstat and confirmed that PostgreSQL instance was listening on port 5552 at last. It took no less than 10 steps to figure this out. 

In a conclusion, I totally understand that every distro packagers have a right to make PostgreSQL configuration process as complex as they want, but with a such popular one as Fedora and the trend to make PostgreSQL easier for new users I find the whole procedure ridiculously complicated. Pushing the changes to the Fedora layout might be hard, but here's one small thing that will make the configuration easier right away: just add a comment to the postgresql.conf shipped with Fedora, describing the process to change the port parameter. 

Now off to do actual work :-)

---
[View this page online](https://www.commandprompt.com/blog/fedora_17_not_so_easy_postgresql_configuration/)