composer:您必须启用openssl扩展才能通过https下载文件

I know this question has been answered in other threads, but having the same problem and not finding the solution for my case in the given answers, I found a different solution for my case and that took me a while to find out, and since I can't reply to those other questions because I have only 1 reputation point, I post it as a new question.

The problem in my case was, that the "extension_dir" setting in my php.ini was wrong, because originally I had installed PHP in a different directory and then moved it manually.

So, if you checked your php.ini and found openssl enabled and still got that error, you may want to also check extension_dir in php.ini, if it points to where you expect it, and if the directory actually contains the openssl module.

check extension_dir in php.ini, can become incorrect after moving a PHP installation to a different folder.

Did you installed your php from source? If so, did you configured it with

./configure --with-config-file-path=/etc/php5/cli --with-openssl

Note about --with-openssl

Once done, it should work.

PS: Do not forget to make && make install