struggling to install PHP pecl on Centos

2020-05-21 04:55发布

I'm trying to install the php_http PHP extension on my CentOS server.

I have done:

yum install php-pear

But get:

No package php-pear available

Yet I can do:

pear

And get a list of commands from Pear.

Same for yum install pecl. I can do pecl but pecl install pecl_http returns:

No releases available for package "pecl.php.net/pecl_http"
install failed

Yet /usr/bin/pecl isn't a directory that exists. Also a sudo pecl install pecl_http returns sudo: pecl: command not found, which I find quite odd.

I'm not entirely sure what's going on here/what I'm doing wrong.

edit: I am using the following repos:

base                         CentOS-6 - Base
epel                         Extra Packages for Enterprise Linux 6 - x86_64
extras                       CentOS-6 - Extras
rpmforge                     RHEL 6 - RPMforge.net - dag
updates                      CentOS-6 - Updates
vz-base                      vz-base
vz-updates                   vz-updates                                                            

8条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-21 05:14

After watching a lot of threads and installing pear and all the devtool, I finally solved it installing this extension:

yum install php-pecl-mongo

as I seen in - https://madcoda.com/2012/12/install-mongodb-php-driver-in-centos-6-3/

查看更多
地球回转人心会变
3楼-- · 2020-05-21 05:19

Whatever your PHP provider is (IUS, Remi or Webtatic), the pear package and the pecl extensions "should" be available there, without any need to compile it from sources (which is usually discouraged, especially on production)

At least "remi" provides most extensions, see the list

So installation should be as simple as

yum install php-pecl-http
yum install php-pecl-lua
etc

And, don't forget to read the Wizard instructions

查看更多
冷血范
4楼-- · 2020-05-21 05:22

if you are running php 7 you might want to try this

yum install php70w-pear

if you get any errors, be sure to uninstall the pear package from any previous attempts

yum remove php-pear

best of luck

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2020-05-21 05:23

For other people having this problem. I discovered this question while trying to figure out why I was having the same problem. Turned out the default configuration at my hosting provider was to include php* in the exclude directive for yum. Check /etc/yum.conf and make sure that the package you're trying to install isn't matched by an entry in the exclude directive.

查看更多
再贱就再见
6楼-- · 2020-05-21 05:24

On CentOS,

  1. Install PHP Pear if not installed yet:

    # yum install php-pear
    
  2. Install GCC if not installed yet:

    # yum install gcc
    
  3. Install cURL if not installed yet:

    # yum install curl-devel
    
  4. Install following libraries if not installed yet:

    # yum install php-devel
    # yum install zlib-devel
    # yum install pcre-devel
    
  5. Start the main installation:

    # pecl install pecl_http
    
  6. Add the following line to /etc/php.ini file

    extension=raphf.so
    extension=propro.so
    extension=http.so
    
  7. Restart apache server so the extension can be loaded

    # service httpd restart
    

You can check if it installed successfully or not:

# pecl list
查看更多
做自己的国王
7楼-- · 2020-05-21 05:29

Centos 6.5 and php7:

sudo su -

yum install yum-utils

you can get last version of lua : http://pecl.php.net/package/lua

wget http://pecl.php.net/get/lua-2.0.4.tgz

tar -xvzf  lua-2.0.4.tgz

cd lua-2.0.4

mkdir  /usr/include/lua

mv * /usr/include/lua

yum install gcc

yum install php70w-pearl php70w-devel



yum install curl-devel

yum install zlib-devel

yum install pcre-devel

ln -s /usr/include/lua.h /usr/include/lua/lua.h

rpm -Uvh https://centos6.iuscommunity.org/ius-release.rpm

yum-config-manager --enable remi-php70

yum update 

yum --enablerepo=remi,remi-php70 install php70w-pear

yum install lua-devel lua-static

pecl install lua-2.0.4
查看更多
登录 后发表回答