2015年9月7日月曜日

Install H2O with PHP7 (RC1)


This is How to Install H2O with PHP7 (RC1). 

Build Environment:
Amazon Linux AMI 2015.03.1 (HVM), SSD Volume Type - ami-1c1b9f1c
c4.xlarge + EBS (General Purpose SSD) 100GB

Install H2O
See Install H2O with PHP5.6.

Install some librarys
# yum -y install libxml2-devel bison bison-devel openssl-devel curl-devel libjpeg-devel libpng-devel libmcrypt-devel readline-devel libtidy-devel libxslt-devel re2c
Install phpenv
# cd /var/tmp
# git clone https://github.com/CHH/phpenv.git
# cd phpenv/bin/
# sh phpenv-install.sh
# export PATH="/root/.phpenv/bin:$PATH"
# eval "$(phpenv init -)"
# source ~/.bashrc
Install php-build & PHP7
# cd /var/tmp
# git clone https://github.com/CHH/php-build.git
# cd php-build/
# sh install.sh
# ./bin/php-build --definitions | grep 7.0
7.0.0alpha1
7.0.0alpha2
7.0.0beta1
7.0.0beta2
7.0.0beta3
7.0.0RC1
# ./bin/php-build 7.0.0RC1 ~/.phpenv/versions/7.0.0RC1
# ~/.phpenv/versions/7.0.0RC1/bin/php -v
PHP 7.0.0RC1 (cli) (built: Sep  4 2015 09:08:33)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Set confilg file
# cp /root/.phpenv/versions/7.0.0RC1/etc/php-fpm.conf.default /root/.phpenv/versions/7.0.0RC1/etc/php-fpm.conf
# cp /root/.phpenv/versions/7.0.0RC1/etc/php-fpm.d/www.conf.default /root/.phpenv/versions/7.0.0RC1/etc/php-fpm.d/www.conf
Run php-fpm
# ~/.phpenv/versions/7.0.0RC1/sbin/php-fpm &
# ps auxf | grep php | grep -v grep
root      2660  0.0  0.0 296828  6240 ?        Ss   09:23   0:00 php-fpm: master process (/root/.phpenv/versions/7.0.0RC1/etc/php-fpm.conf)
nobody    2661  0.0  0.0 296828  5824 ?        S    09:23   0:00  \_ php-fpm: pool www
nobody    2662  0.0  0.0 296828  5828 ?        S    09:23   0:00  \_ php-fpm: pool www
Check
# curl -v http://localhost/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 04 Sep 2015 09:25:07 GMT
< Server: h2o/1.5.0alpha-1
< Connection: keep-alive
< x-powered-by: PHP/7.0.0RC1
< content-type: text/html; charset=UTF-8
< transfer-encoding: chunked
<
* Connection #0 to host localhost left intact
1
Do Apache Bench
# ab -c 10 -n 10000 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        h2o/1.5.0alpha-1
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        1 bytes

Concurrency Level:      10
Time taken for tests:   0.546 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1700170 bytes
HTML transferred:       10001 bytes
Requests per second:    18300.54 [#/sec] (mean)
Time per request:       0.546 [ms] (mean)
Time per request:       0.055 [ms] (mean, across all concurrent requests)
Transfer rate:          3038.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0    0   0.5      0      15
Waiting:        0    0   0.5      0      15
Total:          0    1   0.5      0      15
ERROR: The median and mean for the total time are more than twice the standard
       deviation apart. These results are NOT reliable.

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      1
  99%      1
 100%     15 (longest request)


Titile pic from Eli White