linux

在CentOS 7上安装phpPgAdmin

发布时间:8年前热度: 3668 ℃评论数:

步骤1:将系统更新为最新状态 

在CentOS 7上,始终建议使用yum将系统更新为最新状态: 

 yum update reboot 
注意:如果应用了内核更新,则只需要重新启动实例。 
服务器重新启动后,使用相同的用户再次登录。 


步骤2:安装Apache Web Server 

由于phpPgAdmin是基于Web的工具,因此需要一个Web服务器才能运行。为了本教程的目的,我们将安装Apache。如果你愿意,你可以自由选择你的Niginx或Lighttpd。 

 yum install httpd systemctl start httpd.service systemctl enable httpd.service 



步骤3:安装PHP 5和必要的扩展 

phpPgAdmin是用PHP编写的,你需要安装PHP 5和一些扩展来提供phpPgAdmin。 

 yum install php php-pgsql 



 步骤4:安装数据库用户凭据 

  默认情况下,PostgreSQL程序将创建一个数据库用户“postgres”。但是,出于安全考虑,您需要创建另一个用于远程登录的数据库用户。 

 su -u postgres 

 psql -U postgres 
在psql shell中: 

CREATE USER pgdbuser CREATEDB CREATEUSER ENCRYPTED PASSWORD 'pgdbpass'; CREATE DATABASE mypgdb OWNER pgdbuser; GRANT ALL PRIVILEGES ON DATABASE mypgdb TO pgdbuser; \q 


步骤5:安装并使用phpPgAdmin 

使用以下命令安装phpPgAdmin: 

 yum install phpPgAdmin 
然后将phpPgAdmin配置为从外部访问: 

 vi /etc/httpd/conf.d/phpPgAdmin.conf 
更换: 

Require local 
为: 

Require all granted 
更换: 

Deny from all 
为: 

Allow from all 
保存并退出: 

:wq 
修改config.inc.php文件: 

sudo vi /etc/phpPgAdmin/config.inc.php 
查找行: 

$conf['servers'][0]['host'] = ''; 
用以下替换行: 

$conf['servers'][0]['host'] = 'localhost'; 
查找行: 

$conf['owned_only'] = false; 
用以下替换行: 

$conf['owned_only'] = true; 
保存并退出: 

:wq 
重新加载PostgreSQL和httpd服务: 

sudo systemctl start postgresql-9.5.service sudo systemctl reload httpd.service 
就这样。现在您可以从浏览器访问phpPgAdmin:http:// [YourServerIP] / phpPgAdmin /。使用我们先前设置的用户名“pgdbuser”和密码“pgdbpass”进行登录。

centos

手机扫码访问