我已经拥有在亚马逊服务器上运行的YII(1.1.14)应用程序。所以我打算使用HTTP2,所以请告诉我任何人在我的应用程序中使用HTTP2的过程是什么。
答案 0 :(得分:0)
尝试h2o和卷曲。从v 1.3开始,h2o支持php-fpm。这是h2o.conf的例子。
file.custom-handler:
extension: .php
fastcgi.connect:
host: 127.0.0.1
port: 9000
type: tcp
listen:
port: 8080
ssl:
certificate-file: /path/to/server.crt
key-file: /path/to/server.key
hosts:
"127.0.0.1.xip.io:8080":
paths:
/:
file.dir: /path/to/public_html
您可以使用使用nghttp2构建的libcurl创建http2请求。您所要做的就是使用CURL_HTTP_VERSION_2_0
。
if (!defined('CURL_HTTP_VERSION_2_0')) {
define('CURL_HTTP_VERSION_2_0', CURL_HTTP_VERSION_1_1 + 1);
}
$url = 'https://http2bin.org/get';
$opts = [
CURLOPT_VERBOSE => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
];
$ch = curl_init($url);
curl_setopt_array($ch, $opts);
curl_exec($ch);
curl_close($ch);
答案 1 :(得分:0)
我还建议给H20一个去。到目前为止它一直很稳定。如果您熟悉YAML或类似的配置,则配置非常简单明了。
这篇文章是为了帮助您开始使用Yii,HHVM和HTTP / 2:https://www.symfony.fi/entry/serving-php-on-http-2-with-h2o-and-hhvm-symfony-wordpress-drupal