「hhvm」の版間の差分

提供: Ubuntu入門
移動: 案内検索
(関連項目)
行157: 行157:
  
 
== 関連項目 ==
 
== 関連項目 ==
 
+
* [[メインページ]]
 
<!-- vim: fileencoding=utf-8 filetype=mediawiki
 
<!-- vim: fileencoding=utf-8 filetype=mediawiki
 
-->
 
-->

2015年5月2日 (土) 10:23時点における版

hhvm (HipHop Virtual Machine) とは、Facebook が開発した PHP の処理系です。

読み方

hhvm
えいち えいち ぶい えむ
HipHop Virtual Machine
ひっぷほっぷ ばーちゃる ましん

概要

hhvm は、Facebook が開発した OSS の PHPの処理系です。 hhvmは、 「PHP を高速処理すること」を目的にしています。PHPをhhvmのHHBCというバイトコードに変換し、中間表現 HHIR に変換し、最適化を行い、x86-64 などのマシンコードに Just-In-Timeコンパイルします。

HHVM 3.5.0

  • PDO エクステンションのエラーハンドリングの改善
  • ビルド時間の短縮
  • エクステンションの導入
  • クロージャをインラインで呼び出すための拡張
  • 非同期ストリームをブロックするための stream_await を導入

lxc 環境を構築する

sudo lxc-create -t ubuntu -n hhvm
sudo lxc-start --name=hhvm

インストール

wget をまずインストールします。

sudo apt install wget

リポジトリにGPG鍵をインポートします。

wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -

リポジトリをパッケージ管理システムに登録します。

echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list

例では、 trusty を選択しています。 http://dl.hhvm.com/ubuntu でリポジトリの新しいのを選択します。古いリポジトリは、依存関係を解決できず、hhvm をインストールできません。

hhvm パッケージをインストールします。

sudo apt update
sudo apt install hhvm
hhvm (3.5.0~trusty) を設定しています ...
update-alternatives: /usr/bin/php (php) を提供するために 自動モード で
/usr/bin/hhvm を使います
********************************************************************
* HHVM is installed.
* 
* Running PHP web scripts with HHVM is done by having your webserver talk to HHVM
* over FastCGI. Install nginx or Apache, and then:
* $ sudo /usr/share/hhvm/install_fastcgi.sh
* $ sudo /etc/init.d/hhvm restart
* (if using nginx)  $ sudo /etc/init.d/nginx restart
* (if using apache) $ sudo /etc/init.d/apache restart
* 
* Detailed FastCGI directions are online at:
* https://github.com/facebook/hhvm/wiki/FastCGI
* 
* If you're using HHVM to run web scripts, you probably want it to start at boot:
* $ sudo update-rc.d hhvm defaults
* 
* Running command-line scripts with HHVM requires no special setup:
* $ hhvm whatever.php
* 
* You can use HHVM for /usr/bin/php even if you have php-cli installed:
* $ sudo /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
********************************************************************
libpaper-utils (1.1.24+nmu2ubuntu3) を設定しています ...
Processing triggers for libc-bin (2.19-0ubuntu6.5) ...
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...

使い方

バージョン

ubuntu@hhvm:~$ hhvm --version
HipHop VM 3.5.0 (rel)
Compiler: tags/HHVM-3.5.0-0-ga90f4733cfa0d8fefdafc7433f758f78cdc75424
Repo schema: b88b6fee8ef78ab638506d212abcbefe74a276ac

コマンドラインオプション

ubuntu@hhvm:~$ hhvm --help
Usage:
 
   hhvm [-m <mode>] [<options>] [<arg1>] [<arg2>] ...
 
Options:
  --help                                display this message
  --version                             display version number
  --php                                 emulate the standard php command line
  --compiler-id                         display the git hash for the compiler
  --repo-schema                         display the repository schema id
  -m [ --mode ] arg (=run)              run | debug (d) | server (s) | daemon |
                                        replay | translate (t)
  -a [ --interactive ]                  Shortcut for --mode debug
  -c [ --config ] arg                   load specified config file
  -v [ --config-value ] arg             individual configuration string in a 
                                        format of name=value, where name can be
                                        any valid configuration for a config 
                                        file
  -d [ --define ] arg                   define an ini setting in the same 
                                        format ( foo[=bar] ) as provided in a 
                                        .ini file
  --no-config                           don't use the default php.ini
  -p [ --port ] arg (=-1)               start an HTTP server at specified port
  --port-fd arg (=-1)                   use specified fd instead of creating a 
                                        socket
  --ssl-port-fd arg (=-1)               use specified fd for SSL instead of 
                                        creating a socket
  --admin-port arg (=-1)                start admin listener at specified port
  --debug-config arg                    load specified debugger config file
  -h [ --debug-host ] [=arg(=localhost)]
                                        connect to debugger server at specified
                                        address
  --debug-port arg (=-1)                connect to debugger server at specified
                                        port
  --debug-extension arg                 PHP file that extends command 'arg'
  --debug-cmd arg                       executes this debugger command and 
                                        returns its output in stdout
  --debug-sandbox arg (=default)        initial sandbox to attach to when 
                                        debugger is started
  -u [ --user ] arg                     run server under this user account
  -f [ --file ] arg                     execute specified file
  -l [ --lint ] arg                     lint specified file
  -w [ --show ] arg                     output specified file and do nothing 
                                        else
  --temp-file                           file specified is temporary and removed
                                        after execution
  --count arg (=1)                      how many times to repeat execution
  --no-safe-access-check arg (=0)       whether to ignore safe file access 
                                        check
  --arg arg                             arguments
  --extra-header arg                    extra-header to add to log lines
  --build-id arg                        unique identifier of compiled server 
                                        code
  --instance-id arg                     unique identifier of server instance
  --xhprof-flags arg (=0)               Set XHProf flags

動作確認

ubuntu@hhvm:~$ echo '<?php echo "Hello HHVM", PHP_EOL;?>' >/tmp/hello.php
ubuntu@hhvm:~$ hhvm /tmp/hello.php
Hello HHVM

lxc 環境を削除する

$ sudo lxc-stop --name=hhvm
$ sudo lxc-destroy --name=hhvm

関連項目