Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 158 lines (100 sloc) 7.134 kb
312dac3 kailoa
anonymous authored
1 ---
2 layout: default
a81e922 Gregory Sitnin page is recreated from history
sitnin authored
3 title: install macos x
312dac3 kailoa
anonymous authored
4 ---
5
a81e922 Gregory Sitnin page is recreated from history
sitnin authored
6 # install macos x
312dac3 kailoa
anonymous authored
7
1317af3 kailoa
anonymous authored
8 Install Webpy 0.1 via darwinports.
9
5490b4e kailoa
anonymous authored
10 Adapted from [macdevlog](http://macdevlog.com/webpy01-install.html)
11
1317af3 kailoa
anonymous authored
12 0. Install [macports](http://macports.org/downloads/DarwinPorts-1.3.1-10.4.dmg).
13
14 1. update macports.
15
16 sudo port selfupdate
17
18 2. Get python.
19
20 sudo port install python24
21
22 3. Install postgreSQL
23
24 sudo port install postgresql81
25
26 4. Get web.py
27
28 curl -O "http://webpy.org/web.py"
29 5. Install Cheetah
30
31 curl -O "http://jaist.dl.sourceforge.net/sourceforge/cheetahtemplate/Cheetah-1.0.tar.gz" gunzip Cheetah-1.0.tar.gz
32 tar -xvf Cheetah-1.0.tar
33 rm Cheetah-1.0.tar
34 cd Cheetah-1.0
35 sudo python ./setup.py install
36 cd ..
37 sudo rm -Rf Cheetah-1.0
38
39 6. Install pyscopg
40
41 The version in darwinports is the older 1.x code branch. Since we've installed Postgres in to a non-standard location, we have to nugde the setup.cfg file just a little bit.
42
43 curl -O "http://initd.org/pub/software/psycopg/psycopg2-latest.tar.gz" tar -xzvf psycopg2-latest.tar.gz
44 rm psycopg2-latest.tar.gz
45 cd psycopg2-2.0.4
46 echo library_dirs=/opt/local/lib/postgresql81 >> setup.cfg
47 echo include_dirs=/opt/local/include/postgresql81 >> setup.cfg
48 sudo python setup.py install
49 cd ..
50 sudo rm -Rf psycopg2-2.0.4
51
52 8. Download [pgadmin](http://www.pgadmin.org/download/macosx.php) (optional)
53
54 9. Setup postgresql
55
56 To create a postgre user and group, we are going to use netinfo. According to reports, Mas OS X 10.5 Leopard will be stripped of netinfo. These commands are likely to be Tiger only.
57
58 First, find an unused userID and groupID. typically anything in the 200s or 300s will be unused on most Mac OS X non-server systems. Let's assumes uid 206 and gid 207
59 If you need to check which uid and gid are in use, the following netinfo commands can be used:
60
61 nireport / /users name uid
62 nireport / /groups name gid
63
5156c35 kailoa
anonymous authored
64 Make the users and groups:
1317af3 kailoa
anonymous authored
65
66 sudo niutil -create / /groups/postgres
67 sudo niutil -createprop / /groups/postgres gid 207
68 sudo niutil -create / /users/postgres
69 sudo niutil -createprop / /users/postgres uid 206
70 sudo niutil -createprop / /users/postgres gid 207
71 sudo niutil -destroyprop / /users/postgres passwd changeme
72
73 Now, we need a data store. We can use the Users/Shared directory for this.
74
75 mkdir /Users/Shared/PostgreSQL
76 sudo mkdir /Users/Shared/PostgreSQL/data
77 sudo chown postgres /Users/Shared/PostgreSQL/data
78 sudo chgrp postgres /Users/Shared/PostgreSQL/data
79 sudo -u postgres /opt/local/lib/postgresql81/bin/initdb -D /Users/Shared/PostgreSQL/data
80
81 The initdb comnmand will take a moment, but output the status and notify you of success at the end.
82
83 10. Starting and stopping postgreSQL
84
85 The -b will launch the process in the backgroud.
86
87 sudo -b -u postgres /opt/local/lib/postgresql81/bin/postmaster -D /Users/Shared/PostgreSQL/data >/Users/Shared/PostgreSQL/logfile 2>&1
88
89 This is how you stop a postgres process.
90
91 sudo -u postgres /opt/local/lib/postgresql81/bin/pg_ctl -D /Users/Shared/PostgreSQL/data stop
92
93 11. Preparing PostgreSQL
94
95 Create a user and a test db. Our user is called webpy and the name of the database is webpydb.
96
97 sudo -u postgres /opt/local/lib/postgresql81/bin/createuser --no-superuser --createdb --no-createrole webpy
98 sudo -u postgres /opt/local/lib/postgresql81/bin/createdb --username=webpy webpydb
99 sudo -u postgres /opt/local/lib/postgresql81/bin/createlang plpgsql webpydb
100 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"
101
102 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.
103
104 12. Hardening PostgreSQL
105
106 During most of these steps, we shell into root. Be careful or your could break something.
107
108 cd /Users/Shared/PostgreSQL/
109 sudo sh
110 cd data
111
112 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.
113
114 mv pg_hba.conf pg_hba.conf.bak
115 sed -e '/^local/ d' -e '/^host / d' pg_hba.conf.bak > pg_hba.conf
116
117 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.
118
119 echo 'local all all md5' >> pg_hba.conf
120 echo 'host all postgres 127.0.0.1/32 md5' >> pg_hba.conf
121 echo 'host samegroup all 127.0.0.1/32 md5' >> pg_hba.conf
122 echo 'host all postgres ::1/128 md5' >> pg_hba.conf
123 echo 'host samegroup all ::1/128 md5' >> pg_hba.conf
124 chown postgres pg_hba.conf
125 exit
126
127 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.
5156c35 kailoa
anonymous authored
128
1317af3 kailoa
anonymous authored
129 sudo -u postgres /opt/local/lib/postgresql81/bin/psql -c "alter user postgres with password 'changeme1'" sudo -u postgres /opt/local/lib/postgresql81/bin/psql -c "alter user webpy with password 'changeme2'"
130 Time to reload and restart pgSQL
131
132 sudo -u postgres /opt/local/lib/postgresql81/bin/pg_ctl -D /Users/Shared/PostgreSQL/data reload
133
134 ---
135
5156c35 kailoa
anonymous authored
136 You can follow the [webpy tutorial](http://webpy.org/tutorial) as long as you make the following change:
1317af3 kailoa
anonymous authored
137
138 web.db_parameters = dict(dbn='postgres', user='webpy', pw='changeme2', db='webpydb')
139
140 Also, you can use the following command to send database SELECT and INSERT querys:
141
5156c35 kailoa
anonymous authored
142 /opt/local/lib/postgresql81/bin/psql webpy webpy SOME_QUERY
1317af3 kailoa
anonymous authored
143
5156c35 kailoa
anonymous authored
144 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.
1317af3 kailoa
anonymous authored
145
146 sudo port install lighttpd
147 curl -O http://www.saddi.com/software/flup/dist/flup-r2028.tar.gz
148
149
150 References:
151
152 * [PostgreSQL 8.1.4 Documentation](http://www.postgresql.org/docs/8.1/interactive/)
153 * [PostgreSQL on Mac OS X](http://developer.apple.com/internet/opensource/postgres.html)
154 * [PostgreSQL for Mac OS X](http://www.macdevcenter.com/pub/a/mac/2002/06/07/postgresql.html?page=1)
155
156
157
5156c35 kailoa
anonymous authored
158 [macports]: http://macports.org/
Something went wrong with that request. Please try again.