刚要入门PHP,然后开始编译环境,先从Postgresql开始...
-----------------------------------------------------------
@H_502_12@|System | CentOS 5.7
-----------------------------------------------------------
遇到的编译postgresql的依赖问题,请转文后补充.yum -y install readline-devel
参考: http://blog.92cto.com/blog/339.html
http://www.postgresql.org/ftp/source/
#mkdir /usr/local/src/postgresql&&cd /usr/local/src/postgresql
#wget http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.gz
解压缩
#tar -zxvf postgresql-9.1.2.tar.gz
#su - -c "useradd -M postgres"
#chown -R postgres:postgres postgresql-9.1.2
配置编译
#./configure --help
#./configure --prefix=/opt/pgsql--sysconfdir=/opt/pgsql/etc
#mkdir/opt/pgsql/data
#chown postgres:postgres /opt/pgsql/data
初始化
# su postgres
bash-3.2$ /opt/pgsql/bin/initdb -D /opt/pgsql/data
The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale en_US.UTF-8. The default database encoding has accordingly been set to UTF8. The default text search configuration will be set to "english". fixing permissions on existing directory /opt/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 32MB creating configuration files ... ok creating template1 database in /opt/pgsql/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgsql server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the -A option the next time you run initdb. Success. You can now start the database server using: /opt/pgsql/bin/postgres -D /opt/pgsql/data or /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start
添加环境变量
#vi /etc/profile
PATH=/opt/pgsql/bin:$PATH
export PATH
#source /etc/profile
启动:
#mkdir /opt/pgsql/logs/
#chown postgres:postgres /opt/pgsql/logs/
#su postgres
bash-3.2$ /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l /opt/pgsql/logs/pgsql.log start
设置启动脚本:
#su -c "cp /usr/local/src/postgresql/postgresql-9.1.2/contrib/start-scripts/linux /etc/rc.d/init.d/postgresql-9.1.2"
#su -c "chmod a+x /etc/rc.d/init.d/postgresql-9.1.2"
#vi /etc/rc.d/init.d/postgresql-9.1.2
#! /bin/sh # chkconfig: 2345 98 02 # description: Postgresql RDBMS # This is an example of a start/stop script for SysV-style init,such # as is used on Linux systems. You should edit some of the variables # and maybe the 'echo' commands. # # Place this file at /etc/init.d/postgresql (or # /etc/rc.d/init.d/postgresql) and make symlinks to # /etc/rc.d/rc0.d/K02postgresql # /etc/rc.d/rc1.d/K02postgresql # /etc/rc.d/rc2.d/K02postgresql # /etc/rc.d/rc3.d/S98postgresql # /etc/rc.d/rc4.d/S98postgresql # /etc/rc.d/rc5.d/S98postgresql # Or,if you have chkconfig,simply: # chkconfig --add postgresql # # Proper init scripts on Linux systems normally require setting lock # and pid files under /var/run as well as reacting to network # settings,so you should treat this with care. # Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net> # contrib/start-scripts/linux ## EDIT FROM HERE # Installation prefix prefix=/opt/pgsql # Data directory PGDATA="/opt/pgsql/data" # Who to run the postmaster as,usually "postgres". (NOT "root") PGUSER=postgres # Where to keep a log file PGLOG="$prefix/logs/pgsql.log" # It's often a good idea to protect the postmaster from being killed by the # OOM killer (which will tend to preferentially kill the postmaster because # of the way it accounts for shared memory). Setting the OOM_ADJ value to # -17 will disable OOM kill altogether. If you enable this,you probably want # to compile Postgresql with "-DLINUX_OOM_ADJ=0",so that individual backends # can still be killed by the OOM killer. #OOM_ADJ=-17 ## STOP EDITING HERE # The path that is to be used for the script PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # What to use to start up the postmaster. (If you want the script to wait # until the server has started,you could use "pg_ctl start -w" here. # But without -w,pg_ctl adds no value.) DAEMON="$prefix/bin/postmaster" # What to use to shut down the postmaster PGCTL="$prefix/bin/pg_ctl" set -e # Only start if we can find the postmaster. test -x $DAEMON || { echo "$DAEMON not found" if [ "$1" = "stop" ] then exit 0 else exit 5 fi } # Parse command line parameters. case $1 in start) echo -n "Starting Postgresql: " test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; stop) echo -n "Stopping Postgresql: " #su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" su $PGUSER -c "$PGCTL stop -D '$PGDATA' -m fast" echo "ok" ;; restart) echo -n "Restarting Postgresql: " su $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; reload) echo -n "Reload Postgresql: " su $PGUSER -c "$PGCTL reload -D '$PGDATA' -s" echo "ok" ;; status) su $PGUSER -c "$PGCTL status -D '$PGDATA'" ;; *) # Print help echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2 exit 1 ;; esac exit 0
#service postgresql-9.1.2 restart
PS: 我机子上本来编译环境已经弄好了,所以可能会有些东西缺了,比如gcc,make 等,可以直接yum
以下是我从lnmp那里看来的依赖包安装(但我自己并没有测试):
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip
Reference :
<<Beginning PHP and Postgresql 8 from Novice to Professional>>
原文链接:https://www.f2er.com/postgresql/196705.html