Home > Backend Development > PHP Tutorial > PHP method example code for opening openssl

PHP method example code for opening openssl

怪我咯
Release: 2023-03-12 19:58:01
Original
1323 people have browsed it

TodayWhen debugging the program, it prompts, please turn on openssl. It turns out that openssl is not turned on in most cases. To enable it, you need to make simple settings

php to turn on openssl Method, in most cases openssl is not turned on. To enable it, you need to make simple settings

How to turn it on under windows:

1: First check php. ini; extension=php_openssl.dll exists? If it exists, remove the preceding comment character ';'. If this line does not exist, add extension=php_openssl.dll.
2: Let’s talk about the php folder: php_openssl.dll, ssleay32.dll, libeay32.dll 3 files are copied to the WINDOWS\system32\ folder.
3: Restart apache or iis (iisreset /restart)

At this point, the openssl function is enabled.

How to open it under Linux:

I am using the cloud host of Jinshang Data, PHP version: 5.2.14
The following plan is based on my host Take an example to explain adding openssl module support to PHP.
Some answers on the Internet say to recompile PHP, add configure parameters, and add openssl support. Here is a method that does not require recompiling.
If PHP exists on the serverIt is best to install the package file. If it has beendeleted, download the PHP installation file with the same version as the one shown on the phpinfo page. I Here is php-5.2.14.tar.gz
It is recommended to download the Sohu mirror, but the NetEase mirror was not found. The address is: http://mirrors.sohu.com/php/
Use the ssh tool to connect to the host.

The code is as follows:

# 下载到/var/www/php5目录下
cd /var/www/php5
wget http://mirrors.sohu.com/php/php-5.2.14.tar.gz
# 解压
tar zxvf php-5.2.14.tar.gz
# 进入PHP的openssl扩展模块目录
cd php-5.2.14/ext/openssl/
/var/www/php5/bin/phpize # 这里为你自己的phpize路径,如果找不到,使用whereis phpize查找
# 执行后,发现错误 无法找到config.m4 ,config0.m4就是config.m4。直接重命名
mv config0.m4 config.m4
/var/www/php5/bin/phpize
./configure --with-openssl --with-php-config=/var/www/php5/bin/php-config
make
make install
# 安装完成后,会返回一个.so文件(openssl.so)的目录。在此目录下把openssl.so 文件拷贝到你在php.ini 中指定的 extension_dir 下(在php.ini文件中查找:extension_dir =),我这里的目录是 var/www/php5/lib/php/extensions
# 编辑php.ini文件,在文件最后添加
extension=openssl.so
# 重启Apache即可
/usr/local/apache2/bin/apachectl restart
Copy after login

Okay, openssl support is now successfully added.

The above is the detailed content of PHP method example code for opening openssl. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template