1.下載源碼包: http://ftp.postgresql.org/pub/source/v9.2.3/postgresql-9.2.3.tar.bz2
2.安裝依賴:apt-get install build-essensial gcc make libreadline6 libreadline6-dev (提醒缺少什麼就安裝什麼)
3.開始編譯:
(1)解壓源碼包到 /home/linux/postgresql-9.2.3
(2)./configure --prefix=/要安裝postgresql到哪個目錄
(3)make(成功提示:All of PostgreSQL successfully made. Ready to install.)
(4)su(切換到root使用者)
(5)make install(成功提示:PostgreSQL installation complete.)
(6)adduser postgres
(7)建立資料目錄:mkdir /你安裝postgresql的目錄/data
(8)修改擁有者:chown postgres /你安裝postgresql的目錄/data
(9)切換到postgres使用者:su - postgres
(10)初始化資料目錄:/你安裝postgresql的目錄/bin/initdb -D /你安裝postgresql的目錄/data(成功提示:Success. You can now start the database server using:
/opt/postgresql-9.2/bin/postgres -D /opt/postgresql-9.2/data
or
/opt/postgresql-9.2/bin/pg_ctl -D /opt/postgresql-9.2/data -l logfile start)
(11)啟動postgresql服務:/你安裝postgresql的目錄/bin/postgres -D /你安裝postgresql的目錄/data >logfile 2>&1 &
(12)建立資料庫:/你安裝postgresql的目錄/bin/createdb test
(13)串連到資料庫:/你安裝postgresql的目錄/bin/psql test
如果成功,你將會看到:(
psql (9.2.3)
Type "help" for help.)