FreeBSD下安装编译PostgreSQL

[摘要]PostgreSQL (发音为Post-gress-cue-ell)宣称自己是世界上最先进的开源数据库。PostgreSQL的狂热者认为它的性能跟Oracle不分上下,而且没有高成本的负担。本文介绍在FreeBSD下安装编译PostgreSQL。

  首先,去PostgreSQL官网下载最新版本。笔者使用Linux x86_64源码编译安装包:postgresql-8.4.2.tar.gz。

1、编译安装PostgreSQL 8.4.2,将源码上传到FreeBSD后,运行下面代码解压编译:

tar zxvf postgresql-8.4.2.tar.gz
cd postgresql-8.4.2
./configure --prefix=http://down.chinaz.com/usr/local/pgsql
make
make install

2、创建PostgreSQL用户,由于PostgreSQL不能用root初始化及启动,所以必须创建一个新的用户

pw groupadd pgsql
pw useradd pgsql -g pgsql -d /data/pgsql -s /bin/csh

3、创建PostgreSQL数据存放目录

mkdir -p /data/pgsql/data
chown -R pgsql:pgsql /data/pgsql/

4、初始化数据库

su pgsql /usr/local/pgsql/bin/initdb -D /data/pgsql/data -E UTF8

5、修改PostgreSQL启动文件

cp contrib/start-scripts/freebsd /usr/local/pgsql/pgsql
vi /usr/local/pgsql/pgsql

#修改PGDATA=http://down.chinaz.com/usr/local/pgsql/data
#为PGDATA=http://down.chinaz.com/data/pgsql/data

#修改PGUSER=postgres
#为PGUSER=pgsql
#保存退出

vi /etc/rc.local

#在其中加上 /usr/local/pgsql/pgsql start
#保存退出

  至此PostgreSQL就算是安装完了,接下来是安装PHP的PostgreSQL支持。

1、做一个libpq.so.5的链接

ln -s /usr/local/pgsql/lib/libpq.so.5 /usr/lib/libpq.so.5

2、重新编译PHP

./configure --prefix=http://down.chinaz.com/usr/local/php --with-config-file-path=http://down.chinaz.com/usr/local/php/etc --with-mysql=http://down.chinaz.com/usr/local/mysql --with-mysqli=http://down.chinaz.com/usr/local/mysql/bin/mysql_config --with-iconv-dir=http://down.chinaz.com/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=http://down.chinaz.com/usr/local --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --disable-ipv6 --without-pear --with-pgsql=http://down.chinaz.com/usr/local/pgsql
make ZEND_EXTRA_LIBS='-liconv'
make install

3、重新启动php-fpm

/usr/local/php/sbin/php-fpm stop
/usr/local/php/sbin/php-fpm start

  如果没有报错,那么整个PostgreSQL安装以及PHP支持就算是完成了。祝大家安装顺利。

PostgreSQL v9.2.1.1 For Linux下载

FreeBSD下安装编译PostgreSQL

界面预览

分享到

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/10998.html