PHP and Http Extension

本文详细记录了在CentOS 7环境下使用PHP 5.6并结合Docker部署过程中遇到的HTTP扩展问题及其解决方案。作者通过调整Dockerfile配置及安装PECL扩展成功解决了httpUrl类未找到的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PHP and Http Extension

Recently I am testing the performance for PHP. I just saw a very ‘easy’ exceptions say http\Url class not found. I was thinking it is easy to fix this and it is just a typo or wrong name.

But I am wrong, it is related to this extension in PHP https://mdref.m6w6.name/ It is PECL/http

First of all, I am using CentOS7, I am using PHP5.6, I am using docker. That brings a lot of environment setting up issues for me.

Here is the Dockerfile, that is the most important things to build the ENV.
#Run a Simple REST API based on playframework

#Prepre the OS
FROM centos:7
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
ENV PERL_MM_USE_DEFAULT 1
ENV AWS_PHP_CACHE_DIR /tmp/awscache

RUN yum install -y gcc make wget
RUN yum install -y mysql-devel
RUN mkdir /install/
WORKDIR /install/

#install perl
RUN wget http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz
RUN tar zxvf perl-5.16.3.tar.gz
WORKDIR /install/perl-5.16.3
RUN ./Configure -des -Dusethreads
RUN make && make install
RUN cpan -fi Log::Log4perl YAML::XS Data::Dumper DBI IOC Redis Time::Piece Path::Class
RUN cpan -fi autodie Thread::Queue threads
RUN cpan -fi DBIx::Connector
RUN cpan DBD::mysql

#install php5.6
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
RUN yum install -y php56w

RUN yum install -y php56w-mysqlnd
RUN yum install -y php56w-common
RUN yum install -y php56w-devel
RUN yum --enablerepo=remi,remi-php56 install -y php-pear

RUN yum install -y php56-php-raphf

#set up php
ADD conf/php.ini /etc/php.ini

RUN echo "usr/\n" | pecl install pecl_http-2.5.6

#Install the Application
RUN mkdir /share/
WORKDIR /share/
ADD dist/jobs-consumerphp-1.0.tgz /share/
RUN mkdir -p /share/jobs-consumerphp-1.0/logs

#Start the Application
RUN mkdir -p /app/
RUN mkdir -p /tmp/awscache
ADD start.sh /app/
WORKDIR /app
CMD [ "./start.sh" ]

And remember that I have these lines in order in php.ini to make it working.
extension=iconv.so
extension=raphf.so
extension=propro.so
extension=http.so

References:
http://stackoverflow.com/questions/21077976/pecl-http-failed-to-load

http://stackoverflow.com/questions/19517095/struggling-to-install-php-pecl-on-centos

https://support.rackspace.com/how-to/install-epel-and-additional-repositories-on-centos-and-red-hat/

https://webtatic.com/packages/php56/
http://rpms.famillecollet.com/enterprise/7/

http://monoclechronicles.net/unable-to-load-http-so/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值