Nov/082
Using PostgreSQL With Ruby on Rails on OS X
Following on from my last post for getting PostgreSQL up and running nicely on Mac OS X, my next task was getting it playing nicely with ruby on rails - I’m off on a rails course next week so I’m getting stuff ready.
It appears that there is currently two/three gem packages for using postgresql with ruby: postgres, ruby-pg, and pg - and from what I can make out, they’re all maintained by the same team now, (postgres was the original package, but it got abandoned - ruby-pg and pg are the replacements). As such, i’ll go with the newer ruby-pg gem…
sudo env ARCHFLAGS="-arch i386" gem install \ ruby-pg -- \ --with-pgsql-lib=/opt/local/lib/postgresql83 \ --with-pgsql-include=/opt/local/include/postgresql83
Then finally, when writing the database.yml entry for connecting to postgresql, we have to define our adapter as follows:
development: adapter: postgresql database: test_dev encoding: unicode host: localhost user: XXXXX password: XXXXX timeout: 5000
Nov/080
Install PostgreSQL on Mac OS X Leopard
This type of guide is all over the internet, but I’m too lazy to search for one every time I want to do this.
So here’s a brief overview of how I got PostgreSQL set-up nicely on Mac OS 10.5…
Setting Up Our Environment
Using a text editor of your choice, add the following lines to the bottom of the /etc/profile file (you’ll need to be an administrator to do this):
# MacPorts export PATH=/opt/local/bin:/opt/local/sbin:$PATH # PostgreSQL export PATH=/opt/local/lib/postgresql83/bin:$PATH
Now before we move on, make sure that you have MacPorts installed.
May/0849
Install PostgreSQL on Ubuntu 8.04
Following up from my old guide to installing PostgreSQL (for Ubuntu 7.10), I thought i’d better do an update for the latest releases…
This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux, and also set up the server so it allows access to other PC’s on your network.
Before we move on, this guide was tested on the current release of Ubuntu Linux, (8.04 - Hardy Heron) and PostgreSQL 8.3, but it should also be applicable to older versions (of Ubuntu and PostgreSQL) and other Debian based distros.
Nov/0711
Install phpPgAdmin on Ubuntu 7.10
Update: These instructions have been tested and work fine in the latest version of Ubuntu (8.04, Hardy Heron).
phpPgAdmin is a web based GUI for administrating a PostgreSQL database server.
Here’s some quick notes on getting it installed easily on Ubuntu 7.10…
In the terminal enter the following:
$ sudo apt-get install phppgadmin
This will set up and install all of the phpPgAdmin packages. It will also set-up and configure Apache and php5 for you too if you haven’t installed these already.
Next we need to create a symlink to phpPgAdmin so that Apache can find it:
$ sudo ln -s /etc/phppgadmin/apache.conf /etc/apache2/conf.d/phppgadmin.conf
Now if you navigate to http://localhost/phppgadmin you should be greeted with the phpPgAdmin screen. If your user account has a PostgreSQL account however, you will be logged in automagically.
Optionally, if you would like to be able to use the phpPgAdmin interface as the default ‘postgres’ administration account,1 you will need to do the following2…
$ sudo gedit /usr/share/phppgadmin/conf/config.inc.php
Now find and change the following line
$conf['extra_login_security'] = true;
to
$conf['extra_login_security'] = false;
Save and close gedit. Now all you need to do is restart Apache.
$ sudo /etc/init.d/apache2 reload
Now if you head on over to http://localhost/phppgadmin all should be ready for you.
-
I am assuming here that you have set-up your PostgreSQL server using my set-up instructions and therefore have a password protected ‘postgres’ account and that logins require passwords. ↩
-
Please make sure you have read the above footnote and understand the security implications of allowing this type of access to your database server - if you have not secured your administration accounts, do it now! ↩
Nov/079
Creating New Accounts in PostgreSQL
Getting a new account set up on PostgreSQL is a simple process…
Create our new user:
$ sudo su postgres -c createuser daz
Then you have to give this new user role a name (I called it daz), and then say ‘y’ to the question “Shall the new role be a superuser?” if you want the user to be an administrator.
Give the user a database password (this does not have to be the same as their unix password):
$ sudo su postgres -c psql
postgres=# ALTER USER daz WITH PASSWORD 'mypassword';
postgres=# \q
Finally, give the new user a database to play with:
$ sudo su postgres -c createdb daz
Pretty straight forward…
Nov/0760
Install PostgreSQL on Ubuntu 7.10
If you are using the latest version of Ubuntu (8.04 - Hardy Heron), you might find these slightly updated instructions useful.
This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux, and also set up the server so it allows access to other PC’s on your network.
Before we move on, this guide was tested on the current release of Ubuntu Linux, (7.10 - Gutsy Gibbon) and PostgreSQL 8.2, but it should also be applicable to older versions (of Ubuntu and PostgreSQL) and other Debian based distros.