在一次使用composer安装laravel框架时,系统提示没有开启openssl支持,
之后再php.ini中开启了openssl但是还是不行,后来运行phpinfo()才发现
根本就没有安装openssl扩展,使用php -i查看编译php时的选项,确实没有
添加--with-openssl,如果重新编译php又觉得很麻烦,后来网上找资料,发现
可以不用重新编译php也能添加扩展模块。
第一步:找到与已安装php版本相同的源代码包,(使用php --version查看php版本)如果之前有源代码包,直接解压,没有网上下载相同版本后再解压。使用命令:tar -zxvf xxxx.tar.gz
第二步:进入解压后的目录,会看到一个ext的目录,进入该目录,其中有一个openssl目录,如下图所示
第三步:进入openssl目录,执行如下命令
1 [root@localhost openssl]# /usr/local/php/bin/phpize //视自己的安装环境而定,找到自己已安装php中的phpize 2 Cannot find config.m4. //提示找不到config.m4文件,执行如下mv操作 3 Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module 4 5 [root@localhost openssl]# ls 6 config0.m4 config.w32 CREDITS openssl.c openssl.mak php_openssl.h README tests xp_ssl.c 7 [root@localhost openssl]# mv config0.m4 config.m4 //将目录中的config0.m4直接改名为config.m4 8 [root@localhost openssl]# /usr/local/php/bin/phpize //再执行一次 9 Configuring for: 10 PHP Api Version: 20160303 11 Zend Module Api No: 20160303 12 Zend Extension Api No: 320160303
接着执行如下命令即可:
1 [root@localhost openssl]# ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config 2 checking for grep that handles long lines and -e... /bin/grep 3 checking for egrep... /bin/grep -E 4 checking for a sed that does not truncate output... /bin/sed 5 checking for cc... cc
make
第五步:编辑php.ini文件
vim /usr/local/php/etc/php.ini //开启extension_dir选项,并指定扩展文件存放目录 //配置文件中默认如下所示 ;extension_dir='./' //开启并配置如下所示 extension_dir='/usr/local/php/etc/extension' //自己指定
如下图所示
编辑php.ini文件,开启openssl扩展,在php.ini文件末尾添加如下代码
1 extension=openssl.so
保存并退出,重启apache,测试如下图所示
https://www.cnblogs.com/iaknehc/p/7628022.html