【发布时间】:2020-02-11 15:30:48
【问题描述】:
系统信息
- Win 10 Pro x64
- PHP 7.3.10 x64 TS
- HTTPD 2.4.34
我已按照本指南生成必要的密钥和证书文件。
How do I allow HTTPS for Apache on localhost?
httpd.conf
LoadModule ssl_module modules/mod_ssl.so
额外/vhosts.conf
<IfModule ssl_module>
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile "${CONF_PATH}/certs/localhost.cert"
SSLCertificateKeyFile "${CONF_PATH}/certs/localhost.key"
...
</VirtualHost>
</IfModule>
php.ini
extension=openssl
[curl]
curl.cainfo="C:\bin\httpd\conf\certs\localhost.cert"
[openssl]
openssl.cafile="C:\bin\httpd\conf\certs\localhost.cert"
这通常是人们会说复制libeay32 和ssleay32 的地方,但只是为了向其他人记录这一点,这些不再是最新版本中包含的文件。他们现在是libcrypto 和libssh。我将它们复制到 Apache bin 目录中。
转到带有phpinfo() 的页面会确认这些设置,并将 SSL 标记为启用。
让我们做一些 HTTPS 请求。
pecl update-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is not responding over http://, failed with message: Connection to `ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
Trying channel "pear.php.net" over https:// instead
Cannot retrieve channel.xml for channel "pear.php.net" (Connection to `ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
好吧,那不好。我看到了一些关于从 PECL 脚本中删除 -n 标志的建议。所以我就这么做了。让我们看看现在有什么不同。
pecl update-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is not responding over http://, failed with message: Connection to `ssl://pear.php.net:443' failed:
Trying channel "pear.php.net" over https:// instead
Cannot retrieve channel.xml for channel "pear.php.net" (Connection to `ssl://pear.php.net:443' failed: )
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
不,实际上更糟。现在关于它为什么失败的细节更少了。
有人对我为什么没有成功有任何额外的见解吗?
【问题讨论】:
-
您是否在
php.ini中启用了php_openssl? -
应该有像
extension=php_openssl.dll这样的行,您可以取消注释并使用。如果没有,只需添加该行并重新启动服务器以查看它是否有效。 -
是的,它已启用。我已经说过了。我提出这个问题是因为这是任何人唯一的答案,但它不起作用。