Home  >  Article  >  Backend Development  >  Detailed explanation of how to enable openssl in php

Detailed explanation of how to enable openssl in php

怪我咯
怪我咯Original
2017-07-12 09:54:575448browse

OpenSSL is a secure socket layer cryptographic library, including major cryptographic algorithms, commonly used key and certificate encapsulation management functions and SSL protocols, and provides a wealth of applications for testing or OtherPurpose use.

After OpenSSL was exposed to serious security vulnerabilities, it was discovered that most websites encrypted through the SSL protocol use an open source software package called OpenSSL. The OpenSSL vulnerability not only affects websites starting with https, hackers can also use this vulnerability to directly launch "Heartbleed" attacks on personal computers. According to analysis, a large number of software on Windows use the vulnerable OpenSSL code library and may be attacked by hackers to capture the memory data on the user's computer.

The following is an introduction to how to enable openssl in php. In most cases, openssl is not enabled. To enable it, you need to make simple settings.

How to enable it in windows:

1: First check whether extension=php_openssl.dll exists in php.ini. 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

Okay, openssl support is now successfully added.

The above is the detailed content of Detailed explanation of how to enable openssl in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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