Home >Backend Development >PHP7 >What to do if PHP7 fails to enable OpenSSL extension
This article will introduce to you the solution to the failure to open the OpenSSL extension in PHP7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Recently I learned the Laravel framework and needed to enable the OpenSSL extension of PHP. I tried many methods on the Internet but failed. Finally, after a long time, I finally succeeded. Now I will write down my experience. To summarize.
The following is my failure experience:
First use the most popular method on the Internet:
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. Change the file in the PHP directory: php_openssl.dll (this file is in the ext file folder), ssleay32.dll, libeay32.dll 3 files are copied to the windows\system32\ folder;
3. Restart apache;
At this point, the openssl function is turned on.
Obviously, I didn’t succeed, so I continued to look for ways.
Then I saw someone on Zhihu encountering the same problem, and later solved it, and also told me the method, so I tried it too. After a while, the method is as follows:
The questioner said it is only for win7, mine is win10, but I still tried it, what if it succeeds
Obviously, there was still no success, so I continued to look for a way.
After that, I tried a few more methods, but still no success. Then I thought about using someone else’s computer to try, so I used a friend’s computer to try. Once, I removed the comment in front of extension=php_openssl.dll in php.ini. The three files were not copied. I restarted Apache and opened phpinfo. It was successful. It was a success. At this time, my heart was broken. Why was mine not working? I had no choice but to continue. Finally, I combined the SSL-related parts of the PHP configuration file php.ini of the two computers and the Apache configuration file http.conf. By comparison, I hope I can find the problem. Finally, I found a little difference. I found that LoadModule ssl_module modules/mod_ssl.so was commented out in my http.conf, while his was not commented out. Immediately remove the comment, restart Apache, open phpinfo, search for OpenSSL, and find three more search records, but it is still not enabled. At this point, I had no choice but to continue searching. The hard work paid off and I finally succeeded.
The following is the final successful method:
I saw an article about some issues that need to be paid attention to when upgrading php5 to php7, including this one:
When restarting Apache, it is reported that curl and openssl extension libraries failed to load (apache log will report an error)
You can copy and replace the libeay32.dll and ssleay32.dll files to the apache\bin directory, and start Apache again
I tried it again and it was successful, so my successful method should be to remove the comments about the openssl extension in php.ini, move the above two files, and restart Apache.
Note: When copying two files to the apache\bin directory, it is best to back up the two files in the original directory in advance. If an overwriting error occurs, just close Apache.
Everyone’s environment may be slightly different, the above content is for reference only.
Recommended learning: php video tutorial
The above is the detailed content of What to do if PHP7 fails to enable OpenSSL extension. For more information, please follow other related articles on the PHP Chinese website!