zhmg23

我们是如此的不同

linux下不重新安装php添加openssl扩展的方法

1、进入到源码扩展目录

# cd /usr/local/src/php-5.6.xx/ext/openssl


注:这里你如果找不到你的php源码包了,就去下载,但一定要与当前版本保持一直!


2、执行phpize,如果不知道phpize在哪,用命令whereis phpize查找

# /usr/local/php/bin/phpize

Cannot find config.m4. 

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

扫行phpize报错了,说找不到config.m4文件


# ls

config0.m4  config.w32  CREDITS  openssl.c  openssl.dsp  openssl.mak  php_openssl.h  README  tests  xp_ssl.c

这里有config0.m4,直接重命名为config.m4

# mv config0.m4  config.m4


然后再次运行phpize

# /usr/local/php/bin/phpize

Configuring for:

PHP Api Version:         20131106

Zend Module Api No:      20131226

Zend Extension Api No:   220131226


3、执行安装

# ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config

# make

# make install 


安装完成后,可以看到php扩展目录下,生成了openssl.so

# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

total 2128

-rwxr-xr-x 1 root root 1105216 Sep  1 17:22 opcache.a

-rwxr-xr-x 1 root root  586472 Sep  1 17:22 opcache.so

-rwxr-xr-x 1 root root  479711 Sep  2 09:08 openssl.so


或者你从当前编译目录的modules文件夹里,把openssl.so拷贝到你的php.ini参数extension_dir 指定的目录也行


4、 编辑php.ini文件,在文件最后添加

extension=openssl.so


5、重启php、nginx(或apache)

phpinfo查看一下扩展安装是否成功

linux下不重新安装php添加openssl扩展的方法 - zhm - 合肥运维

 


以上方法,也可适合于linux下,不重新安装php,添加php其他扩展的方法。

评论