linux安装postgresql和配置php扩展

上传人:自*** 文档编号:79098092 上传时间:2019-02-16 格式:DOCX 页数:5 大小:48.92KB
返回 下载 相关 举报
linux安装postgresql和配置php扩展_第1页
第1页 / 共5页
linux安装postgresql和配置php扩展_第2页
第2页 / 共5页
linux安装postgresql和配置php扩展_第3页
第3页 / 共5页
linux安装postgresql和配置php扩展_第4页
第4页 / 共5页
linux安装postgresql和配置php扩展_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《linux安装postgresql和配置php扩展》由会员分享,可在线阅读,更多相关《linux安装postgresql和配置php扩展(5页珍藏版)》请在金锄头文库上搜索。

1、本文档介绍如何使用tar包在Linux(我用的centos5.5)下编译安装pgsql和配置php-pgsql扩展,使php能够连接pgsql数据库。一安装postgresql数据库1.首先到postgresql 官网http:/www.postgresql.org/下载安装包,这里用的是postgresql-8.4.0.tar.gz这个版本。2.开始安装为pgsql创建系统用户组和用户rootlocalhost src groupadd postgresql /新增postgreql用户组rootlocalhost src useradd g postgresql postgres /新增p

2、ostgres用户属于postgresql用户组rootlocalhost src passwd postgres /修改postgres用户密码,回车后输入密码解压安装包并编译安装rootlocalhost src tar xzvf postgresql-8.4.0.tar.gz rootlocalhost src cd postgresql-8.4.0rootlocalhost postgresql-8.4.0 ./configure -prefix =/usr/local/pgsqlrootlocalhost postgresql-8.4.0 gmakerootlocalhost pos

3、tgresql-8.4.0 gmake install配置环境变量rootlocalhost postgresql-8.4.0 vi /etc/profile /配置环境变量,打开profile文件,加入以下配置LD_LIBRARY_PATH=/usr/local/pgsql/libexportLD_LIBRARY_PATHPATH=/usr/local/pgsql/bin:$PATHexportPATHMANPATH=/usr/local/pgsql/man:$MANPATHexportMANPATHrootlocalhost postgresql-8.4.0 source /etc/pro

4、file /使环境变量生效建立数据库集群rootlocalhost postgresql-8.4.0 mkdir /usr/local/pgsql/data /新建数据文件目录rootlocalhost postgresql-8.4.0 chown-Rpostgres.postgres/usr/local/pgsql/data/更改数据文件目录的属主为postgresrootlocalhost postgresql-8.4.0 su postgres /切换到postgres用户下postgreslocalhost postgresql-8.4.0 cd /usr/local/pgsql/bi

5、npostgreslocalhost bin ./initdb-locale=C-E UNICODE D ./data/初始化数据库,设置locale为C,并且template1编码为UNICODE,使数据库支持中文初始化成功后,出现以下运行结果Success.Youcannowstartthedatabaseserverusing:./postgres-D./dataor./pg_ctl-D./data-llogfilestart配置和启动、关闭数据库postgreslocalhost bin su /切换到root用户下rootlocalhost bin touch/var/log/pgs

6、ql.log /新建日志文件rootlocalhost bin chownpostgres/var/log/pgsql.log /更改文件所属用户为postgresrootlocalhost bin su postgres /切换到postgres用户postgreslocalhost bin cd/usr/local/pgsql/data postgreslocalhost data vi postgresql.conf /打开配置文件,去掉下面两行前面的#注释,并将监听地址改为*。listen_addresses=*#whatIPaddress(es)tolistenon;port=543

7、2#(changerequiresrestart)postgreslocalhost data cd ./bin /切换到pgsql 的bin目录postgreslocalhost bin ./postmasterD/usr/local/pgsql/data/var/log/pgsql.log2&1& /启动数据库postgreslocalhost bin ./pg_ctlstop-D/usr/local/pgsql/data /关闭数据库的命令cp /usr/local/src/postgresql-8.4.0/contrib/start-script/linux /etc/rc.d/rc.

8、pgsql /从解压出来的安装包中拷贝启动脚本到/etc/rc.d/目录下,并重命名为rc.pgsqlpostgreslocalhost bin chmod +x /etc/rc.d/rc.pgsql /为启动脚本增加可执行权限postgreslocalhost bin vi /etc/rc.d/rc.pgsql /打开启动脚本,加入以下配置prefix=/usr/local/pgsqlPGDATA=/usr/local/pgsql/dataPGUSER=postgresPGLOG=/var/log/pgsql.logpostgreslocalhost bin /etc/rc.d/rc.pgs

9、qlrestart /使用启动脚本重启数据库开启远程连接postgreslocalhost bin cd ./data /从bin目录切换到data下postgreslocalhost bin vi /usr/local/pgsql/data/pg_hba.conf在#IPv4localconnections:hostallall127.0.0.1/32 trust后增加hostallpostgres0.0.0.0/0md5重新启动数据库就可以远程连接了。/附,其他数据库操作创建数据库dm:./createdbdm创建用户:./createuser-A-D-E-PdmEnterpassword

10、fornewrole:123456Enteritagain:123456Shallthenewrolebeallowedtocreatemorenewroles?(y/n)yCREATEROLE使用psql:./psql-ddm-UdmWelcometopsql8.2.4,thePostgreSQLinteractiveterminal.Type:copyrightfordistributiontermshforhelpwithSQLcommands?forhelpwithpsqlcommandsgorterminatewithsemicolontoexecutequeryqtoquitdm=q在psql中若需要使用中文,先发送:用户名=setclient_encodingtogbk;二配置php-pgsql扩展。1.编译安装php的时候,加入关联pgsql的安装目录,-with-pgsql=/usr/local/pgsql2.安装pgsql扩展yum install php-pgsql然后就可以编写程序进行测试了。5

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号