æ°ãPHPã¨H2OãfastCGIã§ã¤ãªã話ã解決編
ååã¾ã§ã®ãããã
- PHPerãH2Oãã¤ãã£ã¦é«éåããã
- è²ã ãã£ããã§ãããï¼
- ã§ããã¡ãã£ã¨è¨å®ã§è§£ããªãæãããªâ¦
- kazuhoãããããããã®ã§ããã
æåã«ãªã
ååã®ãã¹ãï¼ãã¯ãªã¢ã§ããç¡äºã«æ¬çªæå ¥ãåºæ¥ãç¶æ ã«ãªãã¾ãã¦ãé é¼ãã¼ã½ã³ç·é¸æãµã¤ãããH2O+PHP7ã¨ããã¤ã±ã¦ãç°å¢ã«ã¢ããã°ã¬ã¼ããã¾ããï¼ï¼ï¼
ãã£ãã pic.twitter.com/MgovQJcthe
— uzulla (@uzulla) 2015å¹´6æ21æ¥
https://doraperson2015.yapcasia.org/doraperson2015.yapcasia.org
æ¯éãµã¤ãã«ã¢ã¯ã»ã¹ããå
ãè¼ããããã³ã«"h2"ãçãã¾ãæ¯éã確èªãã ããï¼ï¼ï¼
ï¼ã»ã¼HTTP/2ãããã³ã«ãè¦ãçºã ãã«ã証ææ¸ãæ°ãã«è³¼å
¥ãã¾ããï¼ï¼ï¼ï¼
æçµçãªè¨å®ãã¡ã¤ã«
pid-file: /var/www/logs/h2o.pid access-log: /var/www/logs/access.log error-log: /var/www/logs/error.log user: nobody listen: 80 listen: port: 443 ssl: certificate-file: /var/www/cert/ssl.crt key-file: /var/www/cert/ssl.key file.custom-handler: extension: .php fastcgi.connect: host: 127.0.0.1 port: 9000 type: tcp hosts: "doraperson2015.yapcasia.org:80": paths: /: redirect: status: 301 url: https://doraperson2015.yapcasia.org/ "doraperson2015.yapcasia.org:443": paths: /auth: file.dir: /var/www/dora-person-election/app/htdocs/auth redirect: url: /auth/index.php/ internal: YES status: 307 /: file.dir: /var/www/dora-person-election/app/htdocs redirect: url: /index.php/ internal: YES status: 307
â» å®éã®è¨å®ãã¡ã¤ã«ã®å ¨è¡ã§ã
è¦äºã«çãã§ãããããã§ç¸å¿ã®è¨å®ã«ãªã£ã¦ããï¼ãããï¼ã®ã¯æåãããã¾ãã
å¾ãä»å¾phpãphp-fpmã§ã¯ãªããH2Oã§ç®¡çããããã«ãªãããããã¾ããããããã¯å¾æ¥ã«åã£ã¦ããã¾ãã
ååã®ãã¹ãï¼ã®è©±
続、PHPとH2OをfastCGIでつなぐ話、暗黒道 - uzullaがブログ
- / 以ä¸ã§ãå®ãã¡ã¤ã«ãåå¨ããªããã¹ã¯ /index.phpã§å ¨é¨å¦çããã
- ããã /form 以ä¸ã¯ /form/index.php ãå¼ã³åºããã
ã¨ããè¯ãããã±ã¼ã¹ãç§ã¯ä¸æãè¨å®ã§ãã¾ããã§ããããkazuhoããããã®ææéãã«ä¿®æ£ãã
/form: file.dir: /var/www/app/htdocs/form redirect: url: /form/index.php/ internal: YES status: 307
ããããã°ã¡ããã¨ãããã¾ãããfile.dirããããªãã®ããã¨ããæããããã¾ãã
kazuhoããææ大å¤ãããã¨ããããã¾ããã
SSLè¨å®ã§ä¸ç¬ã¤ã¾ã£ãæ
nginxããããªãã§ããã証ææ¸ãã¡ã¤ã«ï¼.crtï¼ã¯CAãIntermediateãçµåãããã®ã«ããå¿ è¦ãããã¾ããApacheã«æ £ãã諸æ°ã«ããã¾ãã¦ã¯ããSSLCACertificateFileãã§å¥ã®ãã¡ã¤ã«ã«æå®ããã§ãããããH2Oã§ã¯ã証ææ¸ã®ï¼ãã¡ã¤ã«ã®ãªãã«å梱ããå¿ è¦ãããã¾ãï¼å¾è¿°ï¼
ã¨ããããè¨å®ãæ¸ãã¦`h2o -m test`ã§ãã¹ãããã¨ãåå¿è ã«ã¯å¤å°è§£ãã¥ããã¨ã©ã¼ã¡ãã»ã¼ã¸ãåºã¾ãã®ã§ãä¸å¿ããã«è¨è¼ãã¦ããã¾ãã
[OCSP Stapling] testing for certificate file:/var/www/cert/ssl.crt fetch-ocsp-response (using OpenSSL 1.0.1f 6 Jan 2014) --issuer option was not used, and failed to extract issuer certificate from the certificate [/var/www/h2o.conf:10] in command listen, [OCSP Stapling] does not work, will be disabled for file:/var/www/cert/ssl.crt
ããã¯ã証ææ¸ã®ãã§ã¤ã³ãã¤ãªãã£ã¦ãã¾ãããå¤åèªè¨¼å±ãçºè¡ããcrtãã¡ã¤ã«ããã®ã¾ã¾æå®ãã¦ãã¾ããcaã®è¨¼ææ¸ï¼ãIntermediateã®è¨¼ææ¸ï¼ãã証ææ¸ã®ãå¾ãã«è¿½è¨ãã¾ããã
ã¤ã¾ã`cat ã証ææ¸ã ãca証ææ¸ã ãIntermediate証ææ¸ã > ssl.crt` ã¿ãããªãããã§ãã*1
ãããã¯ãããããã¨ã©ã¼ãã§ãããããã¾ããã
[/var/www/h2o.conf:11] in command listen, failed to load private key file:/var/www/cert/ssl.key 140246669301760:error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch:x509/x509_cmp.c:355:
証ææ¸ã¨ãæå·éµãä¸è´ãã¦ãªãããã§ããã証ææ¸ãã¨ãã¾ã¡ããã¦ããªããã°ãåè¿°ã®ã³ããã®é åºãééã£ã¦ããã§ãããï¼å®é俺ã¯ééããã®ã§ãã®æç« ãæ¸ãã¦ããï¼ã
æ®ä½æ¥
å®éã«éç¨ãã¦ããã«ã¯ãh2oãããããä¸ãããåèµ·åãããããå¿ è¦ãããã¾ãã
Quick Start - Configure - H2O - the optimized HTTP/2 server
ãããªæãã§èµ·åãã¦ã % sudo h2o -m daemon -c /path/to/the/configuration-file ãããªæãã§çµäºãã % sudo kill -TERM `cat /path/to/the/pid-file`
ã¨ãããã¥ã¡ã³ãã«ã¯ããã¾ããHUPãéãã°ãªãã¼ãããããããã§ãï¼å¥étestã¯ãã¾ãããï¼ã
ç°å¢ã«ãããã¾ãããsysvã¹ã¿ã¤ã«ã®initã¹ã¯ãªããã¨ããupstartã¨ãã®ã¿ã¬ãä»å¾å¿ è¦ã«ãªãã¾ããï¼ã¾ã æ¸ãã¦ç¡ãï¼ã
ã¡ãªã¿ã«ã`-m daemon`ã¨ããã¨h2oãèªåã§åãã®ã§ã¯ãªããè£ã§ã¯start_serverï¼Server::Starterï¼ã¹ã¯ãªããããåºå®ãã¹ã«ãããã¨ãåæã«å¼ã³åºããã¾ãã
ï¼ã ããã§ã横çãã¦make installã¾ã§ãããªãã¨ãh2o -m daemonã¯ã¤ãããªãï¼
ããã辺ã¯ããªããªãä»ã®httpdã¨ã¯ã¹ã¿ã¤ã«ãéãæãã§ããã
ãã¨ã¯
- ãã£ããHTTP/2ãªãã§ããããPrefetchã¨ãããã¦ã¿ããï¼ã¾ã ãã£ã¦ãªãï¼ã
- PHPã®ããã»ã¹ç®¡çãH2Oã«ã¾ãããã®ããããï¼ãã®ãã¡è©¦ãï¼ã
- ååã®ãã¹ãï¼ãããããã¨ãããã°ã§ããããï¼ãã®ãã¡è©¦ãï¼ã
ã¨ããæãã§ããããã
ã¾ã¨ã
H2O+PHP7ãæ¬çªã«æå ¥ãããã¼ï¼ã ãPHPerã®æ¦ãã¯ããããã ï¼
ãã¡ãããã¯ä»¥ä¸ã§ãã
*1:ï¼ã¤ã®ãã¡ã¤ã«ã®ä¸ã«ãé çªã«ã³ãããã¦ãããã¨ãããã¨ã§ã
*2:Apacheãnginxã¨ã¯ããªãç°ãªããæ¥æ¬çç¾å ´ã®ã¹ã¿ã¤ã«æãæãããpstreeã¿ã¦ãã¨ã¸ã¼ã¼ã£ã¦ãªããã©ãstart_serverã¸ã®å¼æ°ã¯ã©ããã£ã¦çæããã¦ããã ï¼ä»ã®ããã¼ã¸ã£ã¨å·®ãæ¿ãããã¨ãã¯ãªãã®ã ããããããããããã¤ãããã§å®ç¾ãã¦ãäºãèããã¨ãåºæ¬server_starterã ããªã®ããª