sudo -u postgres /opt/local/lib/postgresql81/bin/psql -c "create group webpydb" sudo -u postgres /opt/local/lib/postgresql81/bin/psql -c "alter group webpydb add user webpy"
If these commands are successful, you should see 'CREATE ROLE', 'CREATE DATABASE', 'CREATE LANGUAGE', 'CREATE ROLE', and 'ALTER ROLE' printed out for the respective commands.
12. Hardening PostgreSQL
During most of these steps, we shell into root. Be careful or your could break something.
Backup the pg_hba.conf file and then remove the 1 line that starts with local and the 2 lines that start with host. These default values are way to insecure.
mv pg_hba.conf pg_hba.conf.bak
sed -e '/^local/ d' -e '/^host / d' pg_hba.conf.bak > pg_hba.conf
Make the conf file secure. These are based off of the [Apple recommended settings](http://developer.apple.com/internet/opensource/postgres.html). Feel free to customize if you know what you are doing.
echo 'local all all md5' >> pg_hba.conf
echo 'host all postgres 127.0.0.1/32 md5' >> pg_hba.conf
echo 'host samegroup all 127.0.0.1/32 md5' >> pg_hba.conf
echo 'host all postgres ::1/128 md5' >> pg_hba.conf
echo 'host samegroup all ::1/128 md5' >> pg_hba.conf
chown postgres pg_hba.conf
Done with root. All that remains is to assign passwords to the username. Have you have ever had that dream where you go to school or work but have forgotten your pants?. Skipping this step is kind of like that part of the dream where the cute girl is laughing and pointing at your open port. Make sure the command outputs 'ALTER ROLE' to verify success.
These folowing two items are for production deployment. You won't not need them if you are just taking a quick look at web.py. If you do want to play with around with a simple server setup, the following commands will get you started.