postgresql Linux:如何安装 DBD::Pg 模块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22264753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:38:28  来源:igfitidea点击:

Linux: How to install DBD::Pg module?

perlpostgresqlperl-moduledbd-pg

提问by Naghaveer R

Postgres DB is already installed. I'm not using system perl I have installed another perl in "/srv/data203806/Migration/CPAN/localperl/bin". When I'm trying to install, It is asking for PATH TO pg_config:

Postgres DB 已安装。我没有使用系统 perl 我在“/srv/data203806/Migration/CPAN/localperl/bin”中安装了另一个 perl。当我尝试安装时,它要求 PATH TO pg_config:

[root1@frmrszvwb023 bin]# ./cpan install DBD::Pg
Reading '/root/.cpan/Metadata'
  Database was generated on Fri, 07 Mar 2014 03:53:02 GMT
Running install for module 'DBD::Pg'
Running make for T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz
Checksum for /root/.cpan/sources/authors/id/T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz ok

  CPAN.pm: Building T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz

    Configuring DBD::Pg 3.0.0
    Path to pg_config?
    No POSTGRES_HOME defined, cannot find automatically
    Warning: No success on command[/srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL]
    'YAML' not installed, will not store persistent state
      TURNSTEP/DBD-Pg-3.0.0.tar.gz
      /srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL -- NOT OK
    Running make test
      Make had some problems, won't test
    Running make install
      Make had some problems, won't install
    Could not read metadata file. Falling back to other methods to determine prerequisites

Please help me to install DBD::Pg? How to get path to pg_config?

请帮我安装DBD::Pg?如何获取 pg_config 的路径?

回答by Fernando Nunes

Just ran into this issue, and on Ubuntu 16.04 Xenial the package you're looking for is:

刚遇到这个问题,在 Ubuntu 16.04 Xenial 上,你要找的包是:

apt-get install libdbd-pg-perl

回答by Uooo

You have to install libpq-dev, e.g. on Ubuntu:

您必须安装libpq-dev,例如在 Ubuntu 上:

sudo apt-get install libpq-dev

回答by user2086514

On CentOS/RH you can fix it by installing perl-DBD-Pg package with yum

在 CentOS/RH 上,您可以通过使用 yum 安装 perl-DBD-Pg 包来修复它

sudo yum install perl-DBD-Pg

回答by Dr.Avalanche

From the README:

自述文件

INSTALLATION:

Before installing, please use the "cpansign -v" program to cryptographically verify that your copy of DBD::Pg is complete and valid. The program "cpansign" is part of Module::Signature, available from CPAN.

By default Makefile.PL uses App::Info to find the location of the PostgreSQL library and include directories. However, if you want to control it yourself, define the environment variables POSTGRES_INCLUDE and POSTGRES_LIB, or define just POSTGRES_HOME. Note that if you have compiled PostgreSQL with SSL support, you must define the POSTGRES_LIB environment variable and add "-lssl" and "-lcrypto" to it, like this:

export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"

The usual steps to install DBD::Pg:

  1. perl Makefile.PL
  2. make
  3. make test
  4. make install

Do steps 1 to 2 as a normal user, not as root!

If the script cannot find the pg_config information itself, it will ask you for the path to it. Enter the complete path to the pg_config file here, including the name of the file itself.

安装:

在安装之前,请使用“cpansign -v”程序以加密方式验证您的 DBD::Pg 副本是否完整且有效。程序“cpansign”是 Module::Signature 的一部分,可从 CPAN 获得。

默认情况下,Makefile.PL 使用 App::Info 来查找 PostgreSQL 库的位置并包含目录。但是,如果你想自己控制它,定义环境变量 POSTGRES_INCLUDE 和 POSTGRES_LIB,或者只定义 POSTGRES_HOME。请注意,如果您已编译支持 SSL 的 PostgreSQL,则必须定义 POSTGRES_LIB 环境变量并向其添加“-lssl”和“-lcrypto”,如下所示:

导出 POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"

安装 DBD::Pg 的通常步骤:

  1. perl Makefile.PL
  2. 制作
  3. 做测试
  4. 进行安装

以普通用户而不是 root 身份执行步骤 1 到 2!

如果脚本无法找到 pg_config 信息本身,它会询问您的路径。在此处输入 pg_config 文件的完整路径,包括文件本身的名称。

If you want to use a module, read the documentation.

如果要使用模块,请阅读文档。

回答by Eugen Konkov

Before installing perl module, you must install client for accessing Postgres DB. I just install server and header files:

在安装 perl 模块之前,您必须安装用于访问 Postgres DB 的客户端。我只安装服务器和头文件:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

回答by Eugen Konkov

You can try:

你可以试试:

locate pg_config

This will show something like:

这将显示如下内容:

/usr/pgsql-10/bin/pg_config
/usr/pgsql-10/include/ecpg_config.h
/usr/pgsql-10/include/ecpg_config_x86_64.h

Then run:

然后运行:

POSTGRES_HOME=/usr/pgsql-10 ./cpan install DBD::Pg

回答by Surrogard

For ArchLinux (or any Distro using Pacman):

对于 ArchLinux(或任何使用 Pacman 的发行版):

pacman -S perl-dbd-pg

回答by RobotNerd

Fedora 29, plenv, perl v5.18.0

Fedora 29、pleenv、perl v5.18.0

Once I got plenv working, I was able to install DBD::Pg with cpanm using these commands:

一旦我让 pleenv 工作,我就可以使用以下命令安装带有 cpanm 的 DBD::Pg:

sudo dnf install postgresql postgresql-devel
cpanm --quiet --notest DBD::Pg