1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux安装php pgsql Linux下apache php+phppgadmin+postgresql安装配置

linux安装php pgsql Linux下apache php+phppgadmin+postgresql安装配置

时间:2018-10-13 16:47:20

相关推荐

linux安装php pgsql Linux下apache php+phppgadmin+postgresql安装配置

操作系统:CentOS

安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstring,首选yum), phppgadmin , postgresql 。

一、配置php项目部署环境

1.关闭Centos默认的selinux:

vi/etc/selinux/config

SELINUX=disabled

重启计算机:

/sbin/init6

2.安装apache(手动安装文件,如:httpd-2.4.4.tar.gz或yum安装均可)

[root@localhostconf]#yuminstallhttpd

默认会安装到/etc/httd/下面

[root@localhostconf]#whichhttpd

/usr/sbin/httpd

安装完毕后,可以先启动服务service httpd start,

然后到浏览器输入地址:http://host:80,正常会出现apache test page的网页。

3.安装php(手动或者yum安装)

[root@localhostconf]#yuminstallphp

[root@localhostconf]#whichphp

/usr/bin/php

[root@localhostconf]#yuminstallphp-pgsql

[root@localhostconf]#yuminstallphp-mbstring

二、安装并配置postgresql数据库

1.正常安装postgresql,可以通过安装包安装或者源码编译安装。

2.修改pg_hba.conf配置文件,使得数据库可以允许外部访问。

具体可以配置为:

#TYPEDATABASEUSERADDRESSMETHOD

#"local"isforUnixdomainsocketconnectionsonly

localallallmd5

#IPv4localconnections:

hostallall127.0.0.1/32md5

hostallall0.0.0.0/0md5

#IPv6localconnections:

hostallall::1/128trust

hostallall0.0.0.0/0trust

三、部署并配置phPgAdmin

1.下载:phpPgAdmin-5.1.tar.gz ,并解压到到/var/www/ phpPgAdmin-5.1目录下;

2.配置所管理的数据库的参数:

[root@web-dev-machinephppgadmin]#vi/var/www/phppgadmin/conf/config.inc.php

其中必须修改的是:

$conf['extra_login_security']=false;

其他的可以根据所管理的PostgreSQL数据库的安装情况类配置,如:

//Displaynamefortheserverontheloginscreen

$conf['servers'][0]['desc']='PostgreSQL';

//HostnameorIPaddressforserver.Use''forUNIXdomainsocket.

//use'localhost'forTCP/IPconnectiononthiscomputer

$conf['servers'][0]['host']='192.168.100.101';

//Databaseportonserver(5432isthePostgreSQLdefault)

$conf['servers'][0]['port']=5432;

//DatabaseSSLmode

//Possibleoptions:disable,allow,prefer,require

//TorequireSSLonolderserversuseoption:legacy

//ToignoretheSSLmode,useoption:unspecified

$conf['servers'][0]['sslmode']='allow';

//Changethedefaultdatabaseonlyifyoucannotconnecttotemplate1.

//ForaPostgreSQL8.1+server,youcansetthisto'postgres'.

$conf['servers'][0]['defaultdb']='template1';

//Specifythepathtothedatabasedumputilitiesforthisserver.

//Youcansettheseto''ifnodumperisavailable.

$conf['servers'][0]['pg_dump_path']='/opt/pg932/bin/pg_dump';

$conf['servers'][0]['pg_dumpall_path']='/opt/pg932/bin/pg_dumpall';

注意:以上pg_dump_path和pg_dumpall_path在phpPgAdmin中执行导出数据库时才调用,所以一开始配置错误可能不会看到报错,执行导出时就会报错。

四、配置php 项目源文件目录以及监听端口

vi/etc/httpd/conf/httpd.conf

首先找到端口(默认为80,根据实际情况,可改可不改)

#Listen:AllowsyoutobindApachetospecificIPaddressesand/or

#ports,inadditiontothedefault.Seealsothe

#directive.

#

#ChangethistoListenonspecificIPaddressesasshownbelowto

#preventApachefromglommingontoallboundIPaddresses(0.0.0.0)

#

#Listen12.34.56.78:80

Listen80

然后是php的文件目录(必须添加自己的项目的目录,可以直接添加到配置文件最后边)

#"/var/www/cgi-bin"shouldbechangedtowhateveryourScriptAliased

#CGIdirectoryexists,ifyouhavethatconfigured.

#

AllowOverrideNone

OptionsNone

Orderallow,deny

Allowfromall

#liuyy

#phpPgAdmin

Alias/phppgadmin"/var/www/phpPgAdmin"

OptionsIndexesMultiviews

AllowOverrideNone

Orderallow,deny

Allowfromall

注意:/phppgadmin才是在浏览器中要输入的地址,而不是文件名(phpPgAdmin)本身。

五、以上配置完毕后,在terminal中重启apache服务:service httpd restart

到浏览器中输入地址:http://ip:port/phppgadmin (默认端口80 可以省略)

正常会出现phppgadmin的管理界面。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。