phpPgAdmin
phpPgAdmin 是一个基于 Web 的工具,使用 PHP 前端来帮助管理 PostgreSQL 数据库。
安装
PhpPgAdmin 需要一个带有 PHP 的 Web 服务器,例如 Apache。要进行设置,请参阅 Apache HTTP Server 和 Apache HTTP Server#PHP。
安装 phppgadminAUR 软件包。
配置
PHP
您需要在 PHP 中启用 pgsql 扩展,方法是编辑 /etc/php/php.ini 并取消注释以下行
extension=pgsql
您需要确保 PHP 可以访问 /etc/webapps。如有必要,将其添加到 /etc/php/php.ini 中的 open_basedir
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps
Web 服务器
Apache
创建 Apache 配置文件
/etc/httpd/conf/extra/phppgadmin.conf
Alias /phppgadmin "/usr/share/webapps/phppgadmin"
<Directory "/usr/share/webapps/phppgadmin">
DirectoryIndex index.php
AllowOverride All
Options FollowSymlinks
Require all granted
# phppgadmin raises deprecated warnings that lead
# to parsing errors in JS
#php_flag display_startup_errors off
#php_flag display_errors off
#php_flag html_errors off
</Directory>
并将其包含在 /etc/httpd/conf/httpd.conf 中
# phpPgAdmin configuration Include conf/extra/phppgadmin.conf
您还需要连接 php7
Include conf/extra/php7_module.conf LoadModule php7_module modules/libphp7.so
默认情况下,所有人都可以看到 phpPgAdmin 页面,要更改此设置,请根据您的喜好编辑 /etc/httpd/conf/extra/phppgadmin.conf。例如,如果您只想从同一台机器访问它,请将 Require all granted 替换为 Require local。
Lighttpd
lighttpd 的 php 设置与 apache 完全相同。在您的 lighttpd 配置中为 phppgadmin 创建一个别名。
alias.url = ( "/phppgadmin" => "/usr/share/webapps/phppgadmin/")
然后在您的配置(server.modules 部分)中启用 mod_alias、mod_fastcgi 和 mod_cgi
确保 lighttpd 设置为提供 php 文件,Lighttpd#FastCGI
重启 lighttpd 并浏览到 https:///phppgadmin/index.php
nginx
确保按照 nginx#nginx 配置 中所示,使用单独的 PHP 配置文件设置 nginx#FastCGI。
使用此方法,您将以 phppgadmin.<domain> 访问 PhpPgAdmin。
您可以设置一个子域名(或域名)以及一个服务器块,例如
server {
server_name phppgadmin.<domain.tld>;
root /usr/share/webapps/phppgadmin;
index index.php;
include php.conf;
}
phpPgAdmin 配置
phpPgAdmin 的配置文件位于 /etc/webapps/phppgadmin/config.inc.php。
如果您的 PostgreSQL 服务器在 localhost 上,您可能需要编辑以下行
$conf['servers'][0]['host'] = ;
改为
$conf['servers'][0]['host'] = 'localhost';
访问您的 phpPgAdmin 安装
您的 phpPgAdmin 安装现已完成。在开始使用之前,您需要通过重启 httpd.service 来重启您的 apache 服务器。
您可以通过访问 https:///phppgadmin/ 来访问您的 phpPgAdmin 安装
故障排除
出于安全原因禁止登录
如果 extra_login_security 为 true,则会拒绝通过 phpPgAdmin 进行的无密码登录或使用某些用户名(pgsql、postgres、root、administrator)的登录。只有在您阅读 FAQ 并了解如何更改 PostgreSQL 的 pg_hba.conf 以启用带密码的本地连接后,才将其设置为 false。
编辑 /etc/webapps/phppgadmin/config.inc.php 并更改以下行
$conf['extra_login_security'] = true;
改为
$conf['extra_login_security'] = false;
然后重启 postgresql.service。