Ubuntu – How to make Postgres start automatically on boot

postgresql

I am new to Ubuntu and I would like to know how to make postgresql start automatically on boot and how to configure my setup so that I can start the postgres server if need be.

I am working on a small rails project and I have been having difficulties with postgres starting correctly. I have had to resort to uninstalling and reinstalling postgres to just get the project up and running just to get work done. I have been using these commands.

sudo apt-get -y update
sudo apt-get purge postgresql* # ending * is important
sudo apt-get install postgresql libpq-dev

from this post

https://stackoverflow.com/questions/17934055/postgresql-cannot-connect-to-server-locally

skipping

sudo add-apt-repository ppa:pitti/postgresql

as it appears it is out of date and there's a comment below about not needing it.

If it helps my pg_hba.conf file appears to be located at

/etc/postgresql/9.1/main

I am running Ubuntu 12.04 on top of chrome os

Thanks all for the help and sorry for the newb question!

Best Answer

If you want to start postgres on startup so that you wont have to restart is all the time simply do:

sudo update-rc.d postgresql enable

this will always start your postgres on boot startup. hope it helps someone