php with openssl directory,为php打扩展openssl 详细步骤

本文详细介绍了在Linux环境下安装Composer时遇到的openssl缺失问题,通过phpize编译并配置openssl扩展的过程,以及如何为Workerman添加pcntl支持的方法。

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

今日在linux下安装composer的时候,发现php没有安装 openssl。导致不能下载composer.phar 。

有两种方法可以解决这个事情:

1、简单 粗暴  暴力  重新编译php 把扩展 打开

2、下载对应的源码 通过 phpize  然后 configure   编译 扩展。

这台服务器,之前我们是怎么扩展的函数,我已经不记得了,我好像是记得有一条命令可以查看,

我当时是使用哪些参数编译的,但也找不到。即使找到了,也很难重新编译后,配置也是需要重新配置的。

因此这里选择 了第二种方案:

于是就有了打扩展,只安装openssl

1、进入php源安装目录

/usr/local/src/phpInstall/php7.2.4/ext

然后进入 openssl 目录

2、通过phpize

可能会报错:Cannot find config.m4.Cannot find config.m4.

Make sure that you run '/usr/local/php/php7/bin/phpize' in the top level source directory of the module

解决办法:直接把这个目录 下的  config0.m4  修改成 config.m4

mv config0.m4  config.m4

然后通过  /usr/local/php/php7/bin/phpize[root@localhost openssl]# /usr/local/php/php7/bin/phpize

Configuring for:

PHP Api Version:         20170718

Zend Module Api No:      20170718

Zend Extension Api No:   320170718

3、编译./configure --with-php-config=/usr/local/php/php7/bin/php-config

4、makeLibraries have been installed in:

/usr/local/src/phpInstall/php-7.2.4/ext/openssl/modules

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH' environment variable

during execution

- add LIBDIR to the `LD_RUN_PATH' environment variable

during linking

- use the `-Wl,--rpath -Wl,LIBDIR' linker flag

- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

Build complete.

Don't forget to run 'make test'.

5、make installInstalling shared extensions:     /usr/local/php/php7/lib/php/extensions/no-debug-non-zts-20170718/

6、配置 php.ini

我的php配置文件保存在  /usr/local/php/php7/etc/php.ini 这里

vim  /usr/local/php/php7/etc/php.ini

把 extension=openssl.so

添加到文件中,保存退出

7、重新启动php-fpm 即可。

注意说明:

其他的php扩展,如果少什么,就和上面一样,这样打上扩展即可。

为php扩展无非就是

phpize

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

make && make install

安装pcntl支持workerman

最近在研究workerman  ,workerman的启动是需要 pcntl 的,我的服务器上没有 pcntl,那么怎么扩展呢?

通过命令行,知道当前的php版本是什么

php -v

[root@localhost pcntl]# cd /usr/local/src/phpInstall/php-7.2.4/ext/pcntl

[root@localhost pcntl]# pwd/usr/local/src/phpInstall/php-7.2.4/ext/pcntl

[root@localhost pcntl]# /usr/local/php/php7/bin/phpize

[root@localhost pcntl]#  ./configure --with-php-config=/usr/local/php/php7/bin/php-config

[root@localhost pcntl]#  make && make install

#然后重复上面的第6步,将 pcntl.so 添加到 php.ini 配置文件中

[root@localhost pcntl]# php -m | grep pcntl

#我们发现php已经支持pcntl扩展了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值