centos7下面php5.6添加postgresql相关扩展【试行】

后端 专栏收录该内容
113 篇文章 0 订阅

下载相关资源

首先,请下载PDO_PGSQL及pq两个扩展包源码。
PDO_PGSQL

pq

我下的是:
这里写图片描述

请上传到centos服务器。
这里写图片描述
上传完毕。

解压及编译

解压后,分别编译扩展。
编译pq扩展
步骤如下:
这里写图片描述

注意,使用phpize的时候需要到扩展根目录用,否则会出现上图的提醒。

设定需要编译的php config路径,注意我的php config在:
这里写图片描述

/usr/bin/php-config

请根据实际选用路径。

./configure --with-php-config=/usr/bin/php-config

这里写图片描述
错误,需要指定pg_config才行。
注意,我的机器pg config在:请自行替换路径

这里写图片描述

./configure --with-pgsql=/usr/pgsql-9.6/bin/pg_config --with-php-config=/usr/bin/php-config

还是错误,查找原因得知:
https://stackoverflow.com/questions/4293111/postgresql-pg-config-bash-pg-config-command-not-found


up vote
13
down vote
favorite
I'm on a Mac building an app in Rails 3 with PostgreSQL...

PostgreSQL is working fine but in the command line I get the following error:

$ pg_config
-bash: pg_config: command not found
Anyone know how to get this setup so I can run pg_config?

Thanks

bash unix postgresql shell path
shareimprove this question
edited Nov 27 '10 at 19:25

jira
2,662920
asked Nov 27 '10 at 18:08

AnApprentice
27k114398725
add a comment
5 Answers
active oldest votes
up vote
38
down vote
accepted
you can install postgresql-devel to get that. in rpm based distro

yum install postgresql-devel
will work

or use

yum provides "*/pg_config"
to get the exact package

shareimprove this answer
answered Nov 27 '10 at 22:05

Unni
7631612
3       
For those who find this answer, this program is now part of the package libpq-dev – Walt W Sep 27 '11 at 20:04
3       
on Ubuntu: sudo apt-get install libpq-dev – tflutre Nov 25 '11 at 18:57
2       
For those who find this answer, I still found this program in postgresql-devel in the CentOS Updates repo with CentOS 5.5 – MattSayar Jul 26 '12 at 22:34
2       
Find it finally, thank you. I'm on CentOS and after yum provides I run: python26 setup.py install build_ext --pg-config /usr/pgsql-9.2/bin/pg_config to run on python 2.6 / postgre 9.2 – chirale Mar 25 '13 at 15:48
2       
+1 for mentioning "provides" – Christian Oct 3 '14 at 12:48
show 1 more comment

up vote
2
down vote
My problem was that pg_config was not in the PATH. So, I first needed to search for pg_config's path by using

yum provides "*/pg_config"
After noting the path, I used this command to install pg gem

gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
That installed pg successfully. The system was a CentOS.

shareimprove this answer
answered Apr 14 '16 at 15:46

Anwar
6051120

Confirmed with Fedora 24: dnf install postgresql-devel gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config – amoyer Jun 30 '16 at 2:51 
add a comment
up vote
1
down vote
In addition to installing postgresql-devel I had to modify the PATH environment variable. E.g. add this to your .bashrc:

export PATH="$PATH:/usr/pgsql-9.4/bin"
shareimprove this answer
answered Oct 27 '16 at 9:57

dimid
2,5691741
add a comment
up vote
0
down vote
pg_config comes with the development files for PostgreSQL. Go to where you got the server daemon from and look for them there.

shareimprove this answer
answered Nov 27 '10 at 19:29

Ignacio Vazquez-Abrams
482k748681006
add a comment
up vote
0
down vote
i have a CentOS 5.11 with postgres 9.0, and python 2.4 , python 2.6 to run openERP 6, trying to install the psycopg2 i allways get the error:

# python26 setup.py install --with-xslt-config=/usr/local/bin/xslt-config --with-xml2-config=/usr/local/bin/xml2-config
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --with-xslt-config not recognized
from :how to install pg_config Later i do :

yum provides "*/pg_config"
i get a list, where we can find

postgresql84-devel-8.4.20-1.el5_10.x86_64 : PostgreSQL development header     files
                                          : and libraries
Repo        : base
Matched from:
Filename    : /usr/bin/pg_config
but if i try to install, its already installed So i use

yum provides "*/pg_config"
later you need install the rigth vertion, for your architecture(32bit or 64bit), in my case was:

yum install postgresql84-devel-8.4.20-1.el5_10.x86_64
then update

yum update
and finally install psycopg2 with pip

pip install psycopg2

好了,执行:

export PATH="$PATH:/usr/pgsql-9.6/bin"
然后继续执行:
./configure  --with-php-config=/usr/bin/php-config

出现:
这里写图片描述

raphf扩展的编译安装

到:
raphf
下载安装包,然后解压编译。
这里写图片描述
这里写图片描述

打开目录

这里写图片描述

执行:
phpize
执行:
./configure  --with-php-config=/usr/bin/php-config

结果如下:
这里写图片描述

这里写图片描述

没有问题,那么正式编译

make && make install

如图:
这里写图片描述

这里写图片描述

莫名其妙的错误,解决方案:

centos编译yaf时make出错

这里写图片描述

这里写图片描述

执行:
yum install pcre-dev
还是报错,找到了说法:

[Unknown type name ‘zend_string’

](https://stackoverflow.com/questions/34264584/unknown-type-name-zend-string)

I am trying to compile APCu cache extension using make && make install.

I get a compilation error regarding not being able to find zend_string or zend_long. Do you guys know what extension I would need for these?

APCu

Thanks :)

php makefile apc php-5.6
share
edited Dec 14 '15 at 13:57

Machavity
20.8k133964
asked Dec 14 '15 at 10:22

Kal
94711743

Nevermind got it from pecl instead pecl install APCu-4.0.10. – Kal Dec 14 '15 at 10:32
1       
Those are PHP 7 type names. You're not using the right version of the extension. – Andrea Dec 14 '15 at 20:33

Yeah realized it should be version 4.0.10. Thank. Answer is and I'll accept :) – Kal Dec 20 '15 at 12:13
add a comment
2 Answers
active oldest votes
up vote
3
down vote
accepted
Those types only exist in PHP 7/Zend Engine 3. You need the PHP 5 version of the extension.

share
answered Dec 20 '15 at 16:43

Andrea
10.1k22150

see dependencies pecl.php.net/package/APCu for compatible versions – Stuart Cardall Jan 26 '16 at 12:46
add a comment

up vote
1
down vote
I try to run:

./configure --with-php-config=/usr/local/php7/bin/php-config
replace

./configure
Success.

share

还是外国的网站全一点,意思是这个版本的扩展可能是针对php7的,需要找一个适合php5的扩展。
请回到
http://pecl.php.net/package/raphf
然后下载1.1.2的版本,2.0以上版本是php7的。
这里写图片描述
这里写图片描述

打开目录,
运行
phpize
运行
./configure --with-php-config=/usr/local/php7/bin/php-config
运行
make && make install
成功。

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

好了,现在这样就是编译成功了,那么我们编译的so文件在哪里???

这里写图片描述

这里写图片描述

在两个地方都有,不过我们当然用的是:

/usr/lib64/php/modules/raphf.so

这个文件了。

-- 打开配置文件
vi /etc/php.ini
-- 加入扩展
编辑/etc/php.ini文件加入配置项
extension=raphf.so

就是这样

这里写图片描述

然后重启php-fpm

systemctl restart php-fpm

pq扩展的编译安装

还记得我们的目的吗?我们是要编译pq的。
那么,返回pq的目录然后执行:

phpize
运行
./configure --with-php-config=/usr/local/php7/bin/php-config
运行
make && make install

然而到了最后一步出现了错误:
这里写图片描述

zend_string 只有php7才有,那么我们采用的版本可能太新了。

回到http://pecl.php.net/package/pq然后看到:

这里写图片描述

所有只能用版本1.0以上
这里写图片描述

然后重复扩展的编译过程

phpize
运行
./configure --with-php-config=/usr/local/php7/bin/php-config
运行
make && make install

成功,然后看看是不是生成so文件了:
这里写图片描述

done
-- 打开配置文件
vi /etc/php.ini
-- 加入扩展
编辑/etc/php.ini文件加入配置项
extension=pq.so

这里写图片描述

重启:

systemctl restart php-fpm

编译PDO_PGSQL扩展

打开目录,执行:

phpize
运行
./configure --with-php-config=/usr/local/php7/bin/php-config
运行
make && make install

到config的时候出现错误:
这里写图片描述

解决方案
stackoverflow


up vote
29
down vote
If you use home brew, you can solve this with a command as simple as:

brew install php55-pdo-pgsql

for other php version, search with:

brew search pgsql

shareimprove this answer
answered Sep 20 '15 at 3:19

Daniel Cukier
4,19894588
1       
This is the better answer (+1). The currently accepted answer suggests to use brew to install autoconf and then to compile PHP from source code. Which is unnecessary work, because you can directly install PostgreSQL, PHP and the phpXX-pdo-pgsql packages - all using brew for Mac OSX. – Alexander Farber Mar 12 '16 at 13:36 

I tried this and the install is successful (I see pdo_pgsql in php -i) but I still get pg_connect() not found errors.. – Nic Cottrell May 30 '16 at 8:45
1       
Actually, this is a better answer. Because almost all developers use some kind of packet manager these days. – Turdaliev Nursultan Nov 23 '16 at 12:38
add a comment
up vote
8
down vote
This worked for me with OSX 10.9.4 «Mavericks»

Install sources

Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:

tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP

cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module

I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:

cd ext/pdo_pgsql
In my case I had the following error:

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. ERROR: `phpize' failed

So I had to use this command:

brew install autoconf
Then:

phpize
After that I tried to do: ./configure

but I had the next problem:

checking for pg_config... not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

So the solution was to specify correct PostgreSQL installation path:

./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.

Then simply add

extension=pdo_pgsql.so to /etc/php.ini 
Run php -m to confirm everything went to plan.

shareimprove this answer
answered Aug 7 '14 at 20:26

Jorge Casariego
11.2k44363
2       
Your approach also works for Yosemite. The only caveats are: to use ./configure --with-pgsql=/usr/local/Cellar/postgresql/9.4.1/ in case of PHP 5.5.20; add extension=pgsql.so to /etc/php.ini (originally php.ini.default). – Igor de Lorenzi Jun 9 '15 at 17:53 
add a comment
up vote
5
down vote
For those who installed php7/ngix/postgres with homebrew

You can install the PostgreSQL module with:

brew install php70-pdo-pgsql
After that, you have to restart the php service:

brew services restart php70
shareimprove this answer
answered Aug 14 '16 at 18:17

ricardo
440721
add a comment
up vote
3
down vote
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so. Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.

shareimprove this answer
answered Oct 11 '15 at 20:53

ievgenii
12429
add a comment
up vote
3
down vote
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

shareimprove this answer
answered Feb 1 '16 at 14:05

Christopher Charles Gorman
391
add a comment
up vote
2
down vote
PostgreSQL by default is installed in a unusual place on MAC OS X:

/Library/PostgreSQL/9.3
Given the location above you can type this:

./configure --with-pgsql=/Library/PostgreSQL/9.3
shareimprove this answer
edited Mar 14 '14 at 14:46

Brad Koch
8,14196286
answered Jan 22 '14 at 5:10

YP Leung
13113
add a comment
up vote
2
down vote
For php56 via brew:

brew install php56-pdo-pgsql
shareimprove this answer
answered Jun 9 '16 at 2:34

ThangTD
52138
1       
I'm on Sierra, and this didn't work for me. Install completed, but no pdo_pgsql appears in in phpinfo() – Black Nov 28 '16 at 4:08 

Hi @Francis, did you check by php -i | grep pdo_pgsql in terminal ? Or restart your webserver to see in browser. Refer to my screen shot: prnt.sc/dcmkcp – ThangTD Nov 28 '16 at 4:11 

Hi - found the issue. Sierra Server of course has at least two PHP instances with their own php.ini files; one in /private/etc and the other in /Applications/Server.app/Contents/ServerRoot/private/etc/php‌​.ini. Thanks – Black Nov 28 '16 at 4:44
1       
Yeah, I intent to tell you to make sure whether php version and its location are correct. Better you should use php with homebrew, not the default one. Because its config will lose when you upgrade your MacOS – ThangTD Nov 28 '16 at 4:47
add a comment
up vote
0
down vote
For those of you having openssl error while make here is the solution

OSX uses openssl 0.98 while installer is searching for 1.0.0

refer this link for instructions

psycopg2 installation error - Library not loaded: libssl.dylib

shareimprove this answer
edited 2 days ago

Community♦
11
answered Apr 18 '14 at 9:49

Majky
749425
add a comment
up vote
0
down vote
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.

To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.

shareimprove this answer

重点在于:
这里写图片描述

需要将pgsql的路径传过去。
注意,网上一大堆解决方案谬论:
例如:
这里写图片描述

文章作者真的有试过吗??可行吗?

重新执行几个步骤,不同的是config的时候要带pgsql的路径:

phpize
运行
./configure  --with-pdo-pgsql=/usr/pgsql-9.6/  --with-php-config=/usr/bin/php-config
运行
make && make install

第二步config成功:
这里写图片描述

第三步编译成功

这里写图片描述

而且,生成so文件在:

/usr/lib64/php/modules/pdo_pgsql.so

那么,打开php.ini添加扩展,然后重启php。

-- 打开配置文件
vi /etc/php.ini
-- 加入扩展
编辑/etc/php.ini文件加入配置项
extension=pdo_pgsql.so

这里写图片描述

systemctl restart php-fpm

好了,运行phpinfo的页面看看扩展是不是生效了。

这里写图片描述

可惜的是,我只看到raphf生效,而pq和pdo那个没有踪影,查找解决方案:
pgsql-so-is-not-loaded-in-php

Ask Question

up vote
7
down vote
favorite
1
I've been tasked to create a PHP app which accesses an existing PostgreSQL database. This is my first time working with Postgre, not to mention the PHP has already been installed in the Linux box on which the app is supposed to run. I have no experience setting up this stuff, I just code.

My question is that I can't seem to get the Postgre extension working in PHP. I checked the php.ini file, there were no "extension=..." lines. So I added "extension=pgsql.so". I then checked the "extension_dir" and found that there were only 2 files in there (ldap.so, phpcups.so), I added a pgsql.so file taken from another Linux box. I restarted httpd. And it does not work. I couldn't find any "pgsql" or "postgre" in phpinfo().

Forgive my noobness. I know too little Linux. I would really appreciate it if you can point me to the right direction.

I used the suggestion given by number5:

Dude, I'm on RedHat. I used the "yum" version of the command you gave, and I got this:

[root@perseus ~]# yum install php-pgsql Loading "installonlyn" plugin Setting up Install Process Setting up repositories Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras error was [Errno 4] IOError: Error: Cannot find a valid baseurl for repo: extras

UNFORTUNATELY, the Linux server I'm using is NOT connected to the Internet. Any other way to install?

php apache php-extension
shareimprove this question
edited May 14 '10 at 8:47
asked May 14 '10 at 7:35

Obay
1,43063760
1       
That looks like a question for ServerFault. – Vladislav Rastrusny May 14 '10 at 8:22

hope you already solved your problem. If not, you can download the required rpms and install using rpm command. wget mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS/… wget mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS/… rpm -ivh *.rpm if it tells you that some deps are missing, you can find it here mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS the download link is assuming that your CentOS is 5.4 x86_64 – number5 May 16 '10 at 15:31

thanks number5, super! – Obay May 17 '10 at 9:04
add a comment
4 Answers
active oldest votes
up vote
9
down vote
accepted
It depends on which Linux distro you are using.

If you are using Ubuntu/Debian, you need to:

sudo apt-get install php5-pgsql
Fedora/CentOS

yum install php-pgsql
usually you can find out which distro you are on by:

ls /etc/*-release
shareimprove this answer
answered May 14 '10 at 7:51

number5
7,88413145

Dude I added some comments above – Obay May 14 '10 at 8:05
add a comment
up vote
3
down vote
On CentOS extensions create separate *.ini file one per each php extension in /etc/php.d

So, don't alter main *.ini file, but create /etc/php.d/pgsql.ini and add there a line

extension=pgsql.so
Then you will need to restart Apache using

service httpd restart
But the best automated way is to just type

yum install php-pgsql
In your case that didn't work because of some problems in yum configuration. Go to /etc/yum-repos.d Type

nano /etc/yum.repos.d/CentOS-Base.repo
Scroll down to [extras] section and ensure it is like this:

#additional packages that may be useful
[extras]
priority=1
name=CentOS-$releasever - Extras
=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Correct it if needed, save file (Ctrl-X) and do the following:

yum clean all
yum upgrade
Afterwards try to repeat

yum install php-pgsql
shareimprove this answer
answered May 14 '10 at 8:21

Vladislav Rastrusny
18.8k1362131

it says: Config Error: File contains parsing errors: file:/etc/yum.repos.d/CentOS-Base.repo [line 41]: '=extras\n' – Obay May 14 '10 at 8:33

Who says? What's your CentOS version? May be, you should remove "priority" string? – Vladislav Rastrusny May 14 '10 at 11:21
add a comment
up vote
1
down vote
Remove the .so file you've copied from the other machine (though it might work, there's no need to take the risk)
Use the distribution's package manager to install the php_pgsql/php5_pqsql module
Restart the apache and try again. Maybe the module has been added to an .ini file automagically
If not, run <?php echo 'ini: ', get_cfg_var('cfg_file_path'); to see which php.ini you have to edit
edit this ini file
restart the apache
shareimprove this answer
answered May 14 '10 at 7:52

VolkerK
76.3k13131196
add a comment
up vote
-2
down vote
My operation system Linux mint kde and there was same issue

pg_connect()
You must install if you are use php5.6

sudo apt-get install php5.6-pgsql
After you must change extention name in "php.ini" file.

;extension=php_pgsql.dll
'dll' to 'so'

For example

extension=php_pgsql.so
shareimprove this answer
edited Jan 13 at 17:53
answered Jan 13 at 17:44

Vugar Ahmedoglu
12
1       
This seems like a different issue. For a start, the OP already had that config line exactly as written. – BoundaryImposition Jan 13 at 17:59
add a comment
Your Answer

centos下面安装php扩展的几种方法

https://my.oschina.net/u/2400083/blog/518195

Centos下,PHP有多种方式来安装拓展, 主要有 包管理式的yum安装、pecl安装, 以及底层的源码编译安装。

包管理式的安装卸载尤为方便,而源码编译式的安装则方便参数调优。

一般的搭建本机开发环境推荐包管理式的安装,节约时间。而线上部署环境则推荐编译安装, 方便调优。



yum安装

## yum方式安装能自动安装拓展的.so动态库,并配置好php.ini

# 如安装mysql拓展
yum search mysql|grep php  #我们搜索到拓展名为 php-mysql.x86_64
sudo yum install php-mysql  #这样php-mysql拓展便安装好了

# 如果出现拓展版本和php版本冲突问题, 可安装如下任意yum源:
sudo yum install atomic-release.noarch
sudo yum install webtatic-release.noarch
# 这些源提供了其他版本的php拓展,同时每个源针对特定拓展都会提供多个版本,你只需安装一个源即可。如:
atomic源下能搜索到5.4版的mysql拓展  atomic-php54-php-mysql.x86_64 
webtatic源下能搜索到5.5版本的mysql拓展 php55w-mysql.x86_64


pecl安装

# 我们需要先从pear官网下载 go-pear 工具
# 这个工具将帮我们同时安装 pecl包管理器(管理php的C拓展) pear包管理器(管理php类库)
wget http://pear.php.net/go-pear.phar

# 安装工具
# 安装过程除非特别指定,否则默认将工具安装到 /home/用户名/pear/bin 目录下
php go-pear.phar

# 将工具目录添加到环境变量中
# 编辑/etc/profile 追加一行配置
export PATH=$PATH:/home/用户名/pear/bin

# 加载环境配置
source /etc/profile

# 配置工具的php_ini选项,这样安装拓展时pecl工具就能帮我们自动配置php.ini文件了
# vim /home/用户名/pear/share/pear/PEAR/Config.php
# 搜索php_ini, default键修改为你的php.ini文件路径:
        'php_ini' => array(
            'type' => 'file',
            'default' => '/etc/php.ini',
            'doc' => 'location of php.ini in which to enable PECL extensions on install',
            'prompt' => 'php.ini location',
            'group' => 'File Locations (Advanced)',
            ),   
#确认一下,配置起效
pecl config-get php_ini  #配置成功将显示 /etc/php.ini

# 搜索mysql拓展
pecl search mysql
# 这时一般会提示我们更新工具, 则我们依据提示进行更新
sudo pecl channel-update pecl.php.net
# 再次搜索mysql拓展, 成功
pecl search mysql

# 安装拓展
pecl install  mysql


源码编译安装

# 以安装phpredis拓展为例
git clone https://github.com/phpredis/phpredis.git  # 下载phpredis源码
cd phpredis/
phpize
./configure
make & make install
cp rpm/redis.ini /etc/php.d/redis.ini




检查mysql拓展是否安装成功

php -i | grep mysql
成功安装后上面命令将显示一个节区的mysql拓展状态信息。

但拓展加载到运行环境中还需要你重启 web服务 亦或是 php-fpm

根据上面的完全不行,然而,我们打开php -v可以看到:
这里写图片描述

解决方案:

undefined-symbol-php_json_decode_ex-in-unknown-on-line-0-solr-so-in-ubuntu

undefined symbol: php_json_decode_ex in Unknown on line 0 – Solr.so in Ubuntu
November 6, 2014 
Make you sure that this line comes before your newly added extension in php.ini

extension=json.so
then add your extension

extension=xyz.so

由此可知,可能是插件加载顺序的问题,那么先加载json.so

这里写图片描述

这里写图片描述

看到pdo这个前缀,不如也将pdo.so加到前面去。

这里写图片描述

这里写图片描述

正常运行,不过说已经加载了。。。算了,可以运行就好了。
这里写图片描述

正式配置完毕

后续补充

pg_connect依然无法使用,就是说,还有一个模块pgsql没有配置,根据网上说法:

上周博主在这篇文章中介绍了php采集,http://www.sijitao.net/1511.html。PHP+PostgreSQL的环境配置其实也不顺利。

首先我在系统中安装了PostgreSQL数据库,用EnterpriseDB包。然后重新编译PHP,在编译中加入--with-pgsql=路径。可是编译后发现还是没有加载php_pgsql扩展。

继续google,我后来也使用过yum install php-pgsql命令安装扩展,但是结果还是一样。

不过功夫不负有心人,问题最后终于还是解决了。

先从http://rpmfind.net/linux/RPM/index.html这个站点分别下载了“php53-common-5.3.3-21.el5.i386.rpm”、“php53-pdo-5.3.3-21.el5.i386.rpm”和“php53-pgsql-5.3.3-21.el5.i386.rpm”三个安装包,分别安装。安装成功后会在/usr/lib/php/modules/目录下生成pgsql.so等扩展。

php_postgresql_1

然后在扩展目录下新建pgsql.so和pdo_pgsql.so链接。

最后修改配置文件,在扩展中加入pgsql.so,重启php。

php_postgresql_2

使用phpinfo查看,发现pgsql扩展已经安装成功,贴上成功图。

php_postgresql_3

1、找到php common,编译安装:

http://www.rpmfind.net/linux/rpm2html/search.php?query=php-common%28x86-64%29&submit=Search+…&system=&arch=
注意:
我这里使用的是:
这里写图片描述
连接是:
ftp://195.220.108.108/linux/centos/7.3.1611/os/x86_64/Packages/php-common-5.4.16-42.el7.x86_64.rpm

执行:

wget ftp://195.220.108.108/linux/centos/7.3.1611/os/x86_64/Packages/php-common-5.4.16-42.el7.x86_64.rpm

这里写图片描述

当然,你也可以这样子下载下来然后上传到服务器

这里写图片描述

安装

rpm -ivh php-common-5.4.16-42.el7.x86_64.rpm

问题如下:

这里写图片描述

好了,根据百度的结果:
这里写链接内容

这里写图片描述

这里写图片描述

yum install libzip

这里写图片描述

安装完毕。继续:

rpm -ivh php-common-5.4.16-42.el7.x86_64.rpm

这里写图片描述

我这边的同样的库已经装过了,而且版本更新,就不需要安装这个php common了。

  • 0
    点赞
  • 1
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

评论1
请先登录 后发表评论~
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页

打赏作者

码农下的天桥

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值