小皮面板Linux下安装php7.3.8的curl模块

小皮面板Linux下安装php7.3.8的curl模块

因单位内网问题,服务进行项目测试,故在阿里云上安装了正在开发的项目进行测试,为了快速部署使用了小皮面板(phpstudy):

环境如下:

centos7.8 php7.3.8 MySQL5.7.2 nginx1.5 thinphp5.1

结果在运行时发现,小皮面板集成的环境中php7.3.8里没有curl模块,导致部分功能无法使用,于是开始了填坑之路。。。。。。

1、下载php源码

到国内网站 http://php.p2hp.com/ ,从历史档案中翻找并下载php7.3.8源码。

下载下来的源码文件为:php-7.3.8.tar.bz2 需要安装bzip2进行解压。

于是又安装解压软件:

yum install -y bzip2 //安装bzip2
bunzip2 php-7.3.8.tar.bz2 //改变压缩格式
tar -xf php-7.3.8.tar.bz2  //解压到当前目录下

2、执行生成curl.so文件

进入解压后的php源代码目录,定位到curl

cd /你的解压目录/php7.3.8/ext/curl

执行生成so文件,先使用phpize进入编译模式,再使用configure命令配置

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/phpstudy/soft/php/php-7.3.8/bin/php-config  --with-curl=/usr/local/phpstudy/soft/php/php-7.3.8/lib/php/extensions/no-debug-non-zts-20180731

注意:./configure 命令中--with-curl路径,是小皮面板安装后php7.3.8的默认路径。真的很长。。。。

但是在执行phpize时又出现错误,错误如下:

Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Cannot find autoconf. Please check your autoconf installation and the  $PHP_AUTOCONF  environment variable is set correctly and then rerun this script.

一顿搜索后,解决方法如下:

 wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
 tar -zvxf m4-1.4.9.tar.gz
 cd m4-1.4.9/
 ./configure && make && make install
 cd ../
 wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
 tar -zvxf autoconf-2.62.tar.gz
 cd autoconf-2.62/
 ./configure && make && make install

继续执行命令,结果又悲剧了。。。。

报错:

Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决报错:

yum install m4
yum -y install autoconf

继续执行./configure,。。。郁闷!报错:

configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

解决报错:

yum install -y libcurl-devel

一番折腾后,继续执行

编译curl扩展

./configure --with-php-config=/usr/local/phpstudy/soft/php/php-7.3.8/bin/php-config  --with-curl=/usr/local/phpstudy/soft/php/php-7.3.8/lib/php/extensions/no-debug-non-zts-20180731

make &&make install

3、修改php.ini文件

经过以上折腾,会在小皮面板的php安装路径下(/usr/local/phpstudy/soft/php/php-7.3.8/lib/php/extensions/no-debug-non-zts-20180731),多出了编译后的curl.so文件。

然后配置文件中开启 curl引用:

  在php.ini 文件中 extension=curl.so //去掉注释,没有就添加一行

​ 最后重启服务,ok了~!

posted @ 2021-03-25 23:49  白开水2021  阅读(498)  评论(0)    收藏  举报