HipHop for PHP 環境の作り方

Windows7上に仮想マシンを構築してHipHop for PHPを試してみました。
以下に環境構築〜動作確認までの手順をまとめておきます。

前提環境

  • VT対応の64bitCPU (私はCorei5 750を使っています)
  • Windows7 Professional 64bit

構築環境

VMware Playerを使用している理由は,Virtual PCで64bitOSが動作しないため。

VMware Playerのインストール

  1. ユーザ登録してダウンロード!
  2. VMware-player-3.0.1-227600.exe をインストール。
  3. isoからインストール
  4. VMware Tools Linuxをインストールする必要ありと言われるので従ってインストール。
  5. OS再起動

CentOSのインストール

OSのインストール

インストーラの指示に従ってデフォルトインストール。

  1. インストール言語:日本語
  2. キーボード:日本語
  3. パーティション:デフォルトのまま
  4. ネットワークデバイス:デフォルトのまま
  5. 地域:アジア/東京
  6. ルート:
  7. ソフトウェア
  8. インストール後再起動
  9. ファイアウォール:無効
  10. SELinux:無効
  11. 日付と時刻:デフォルトのまま
  12. ユーザの作成:お任せ
  13. 追加のCDデフォルトのまま
  14. 再起動

HipHop for PHPのビルドとインストール

[user@localhost ~]$ su -
[root@localhost ~]# mkdir build
[root@localhost ~]# cd build
[root@localhost build]# yum install yum-priorities
[root@localhost build]# wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[root@localhost build]# rpm -import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
[root@localhost build]# rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
rpmforge-release-0.3.6-1.el5.rf.i386.rpm: (sha1) dsa sha1 md5 gpg OK
[root@localhost build]# rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm
[root@localhost build]# yum check-update
[root@localhost build]# vim /etc/yum.repos.d/rpmforge.repo
enabled = 0 に変更
[root@localhost build]# yum install \
  binutils-devel \
  bison \
  cmake \
  curl-devel \
  distcc \
  expat-devel \
  gcc gcc-c++ \
  gd gd-devel \
  git \
  libcap-devel \
  libevent-devel \
  libmcrypt-devel \
  libssh2 \
  libxml2-devel \
  mysql-server mysql-devel \
  openssl-devel \
  pcre-devel \
  re2c \
  --enablerepo=rpmforge
[root@localhost build]# wget http://www.kernel.org/pub/software/scm/git/RPMS/x86_64/git-1.5.6.1-1.x86_64.rpm
[root@localhost build]# wget http://www.kernel.org/pub/software/scm/git/RPMS/x86_64/perl-Git-1.5.6.1-1.x86_64.rpm
[root@localhost build]# rpm -U git-1.5.6.1-1.x86_64.rpm perl-Git-1.5.6.1-1.x86_64.rpm 

[root@localhost build]# wget http://www.threadingbuildingblocks.org/uploads/77/142/2.2/tbb22_20090809oss_lin.tgz
[root@localhost build]# tar xvzf tbb22_20090809oss_lin.tgz
[root@localhost build]# export TBB_INSTALL_DIR="/root/build/tbb22_20090809oss"
[root@localhost build]# export TBB_ARCH_PLATFORM="intel64/cc4.1.0_libc2.4_kernel2.6.16.21"

[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/boost-1_37_0-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/boost-debuginfo-1_37_0-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/boost-devel-1_37_0-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/icu-4.2.1-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/icu-debuginfo-4.2.1-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/libicu42-4.2.1-1.x86_64.rpm
[root@localhost build]# wget http://github.com/downloads/johnwyles/hiphop-rpm-centos/libicu-devel-4.2.1-1.x86_64.rpm
[root@localhost build]# rpm -ivh \
  icu-4.2.1-1.x86_64.rpm \
  libicu42-4.2.1-1.x86_64.rpm \
  libicu-devel-4.2.1-1.x86_64.rpm \
  icu-debuginfo-4.2.1-1.x86_64.rpm \
  boost-1_37_0-1.x86_64.rpm \
  boost-devel-1_37_0-1.x86_64.rpm \
  boost-debuginfo-1_37_0-1.x86_64.rpm

[root@localhost build]# wget http://downloads.sourceforge.net/project/flex/flex/flex-2.5.35/flex-2.5.35.tar.gz?use_mirror=jaist
[root@localhost build]# tar xvzf flex-2.5.35.tar.gz
[root@localhost build]# cd flex-2.5.35
[root@localhost flex-2.5.35]# ./configure && make && sudo make install
[root@localhost flex-2.5.35]# cd ..

[root@localhost build]# wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.2.tar.gz
[root@localhost build]# tar xvfz onig-5.9.2.tar.gz
[root@localhost build]# cd onig-5.9.2
[root@localhost onig-5.9.2]# ./configure && make && sudo make install
[root@localhost onig-5.9.2]# cd ..

[root@localhost build]# git clone git://github.com/facebook/hiphop-php.git

[root@localhost build]# wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
[root@localhost build]# tar xvzf libevent-1.4.13-stable.tar.gz
[root@localhost build]# cd libevent-1.4.13-stable
[root@localhost libevent-1.4.13-stable]# cp ../hiphop-php/src/third_party/libevent.fb-changes.diff .
[root@localhost libevent-1.4.13-stable]# patch < libevent.fb-changes.diff
[root@localhost libevent-1.4.13-stable]# ./configure && make && sudo make install
[root@localhost libevent-1.4.13-stable]# cd ..

[root@localhost build]# wget http://curl.haxx.se/download/curl-7.20.0.tar.gz
[root@localhost build]# tar xvzf curl-7.20.0.tar.gz
[root@localhost build]# cd curl-7.20.0
[root@localhost curl-7.20.0]# cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff .
[root@localhost curl-7.20.0]# patch -p0 < libcurl.fb-changes.diff
[root@localhost curl-7.20.0]# ./configure && make && sudo make install
[root@localhost curl-7.20.0]# cd ..

[root@localhost build]# export CMAKE_PREFIX_PATH=/root/build
[root@localhost build]# cd hiphop-php/
[root@localhost hiphop-php]# git submodule init
[root@localhost hiphop-php]# git submodule update
[root@localhost hiphop-php]# export HPHP_HOME=`pwd`
[root@localhost hiphop-php]# export HPHP_LIB=`pwd`/bin
[root@localhost hiphop-php]# cmake .
[root@localhost hiphop-php]# make

HipHop for PHPの動作確認

[root@localhost hiphop-php]# export TBB_INSTALL_DIR="/root/build/tbb22_20090809oss"
[root@localhost hiphop-php]# export TBB_ARCH_PLATFORM="intel64/cc4.1.0_libc2.4_kernel2.6.16.21"
[root@localhost hiphop-php]# export HPHP_HOME=`pwd`
[root@localhost hiphop-php]# export HPHP_LIB=`pwd`/bin
[root@localhost hiphop-php]# vi test.php
<?php
echo 'Hello hiphop-php!!';

[root@localhost hiphop-php]# src/hphp/hphp test.php