takafumi blog

日々の勉強メモ

hhvm Hack その3/webサーバーとして動かす

CentOS6.5 hhvm3.2.0

hhvmはwebサーバーとしても起動できます。

まず設定ファイルを触っておきます

$ cd /etc/hhvm
$ cp -a config.hdf config.hdf.ORI
$ vim config.hdf
$ diff -u config.hdf.ORI config.hdf
--- config.hdf.ORI      2014-02-14 22:07:27.000000000 +0900
+++ config.hdf  2014-09-24 07:13:04.249376859 +0900
@@ -1,3 +1,7 @@
+Server {
+  Port = 80
+  SourceRoot = /var/www/hhvm
+}
 Log {
   Level = Warning
   AlwaysLogUnhandledExceptions = true

webサーバー起動

$ hhvm -m daemon --config /etc/hhvm/config.hdf
Fail to bind port 80: 98 Address already in use

あれ?

$ lsof -nPi | grep ':80'
httpd   15042     root    4u  IPv6  50043      0t0  TCP *:80 (LISTEN)

chkconfigがonだったの自動起動してました。
httpdを止めてもう一度。

$ hhvm -m daemon --config /etc/hhvm/config.hdf
$ lsof -nPi | grep ':80'
hhvm    15148     root   17u  IPv4  50790      0t0  TCP *:80 (LISTEN)
$ get -q "http://localhost/hello.hh" -O -
Hello Hack on hhvm

バッチリです。