大多数开发人员都对 Facebook 的 Hiphop for php 有所了解,我想在我的脚本中使用它,但不知道从哪里开始。
我应该与我的服务器提供商交谈吗?或者我需要在我的脚本中添加一些代码吗?
HipHop 很难安装,但幸运的是我刚刚经历过!
您需要一个专用服务器,该服务器最容易安装在 Red Hat 或 CentOS 或 Amazon Linux 上。您不能将其安装在共享主机上,您需要 root 访问权限。
在干净的服务器(仅操作系统)上安装也更容易。
我建议您从 Amazon Web Services 获取一个干净的实例并将其安装在上面,您可以在不需要时将其关闭。它并不昂贵。
这会将其安装在 AWS 实例上,一次将其放入 SSH 中:
<!-- language: sh -->
sudo su -
export LDFLAGS="$LDFLAGS -lrt"
export CMAKE_PREFIX_PATH=/home/ec2-user/hiphop/local
export HPHP_HOME=/home/ec2-user/hiphop/hiphop-php
export HPHP_LIB=/home/ec2-user/hiphop/hiphop-php/bin
ldconfig
yum -y install git cmake boost pcre-devel libicu-devel libmcrypt-devel oniguruma-devel mysql-devel gd-devel boost-devel libxml2-devel libcap-devel binutils-devel flex bison expat-devel patch gcc gcc-c++ bzip2 bzip2-devel memcached openldap openldap-devel readline-devel libc-client-devel pam-devel
mkdir /home/ec2-user/hiphop
cd /home/ec2-user/hiphop
git clone git://github.com/facebook/hiphop-php.git
wget "http://downloads.sourceforge.net/project/re2c/re2c/0.13.5/re2c-0.13.5.tar.gz?use_mirror=cdnetworks-us-2"
wget "http://www.threadingbuildingblocks.org/uploads/77/142/2.2/tbb22_20090809oss_src.tgz"
wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2
wget http://www.monkey.org/~provos/libevent-1.4.14-stable.tar.gz
wget http://launchpad.net/libmemcached/1.0/0.48/+download/libmemcached-0.48.tar.gz
tar xvjf curl-7.20.0.tar.bz2
tar xvzf libevent-1.4.14-stable.tar.gz
tar xvzf re2c-0.13.5.tar.gz
tar xvzf tbb22_20090809oss_src.tgz
tar xvzf libmemcached-0.48.tar.gz
export LDFLAGS="$LDFLAGS -lrt"
export CMAKE_PREFIX_PATH=/home/ec2-user/hiphop/local
cd /home/ec2-user/hiphop/tbb22_20090809oss
gmake
cp -Rp include/tbb/ /usr/include/
cp /home/ec2-user/hiphop/tbb22_20090809oss/build/*_release/*.so /usr/lib/
cp /home/ec2-user/hiphop/tbb22_20090809oss/build/*_release/*.so.2 /usr/lib/
ldconfig
cd /home/ec2-user/hiphop/re2c-0.13.5
./configure --prefix=/home/ec2-user/hiphop/local
make install
cd /home/ec2-user/hiphop/libevent-1.4.14-stable
cp /home/ec2-user/hiphop/hiphop-php/src/third_party/libevent-1.4.14.fb-changes.diff .
patch < libevent-1.4.14.fb-changes.diff
./configure --prefix=/home/ec2-user/hiphop/local
make install
cd /home/ec2-user/hiphop/curl-7.20.0
cp /home/ec2-user/hiphop/hiphop-php/src/third_party/libcurl.fb-changes.diff .
patch -p1 < libcurl.fb-changes.diff
./configure --prefix=/home/ec2-user/hiphop/local
make install
cd /home/ec2-user/hiphop/libmemcached-0.48
./configure --prefix=/home/ec2-user/hiphop/local
make install
cd /home/ec2-user/hiphop/hiphop-php
git submodule init
git submodule update
export HPHP_HOME=/home/ec2-user/hiphop/hiphop-php
export HPHP_LIB=/home/ec2-user/hiphop/hiphop-php/bin
cmake .
make
alias hphp=/home/ec2-user/hiphop/hiphop-php/src/hphp/hphp
然后每次登录 SSH 时,粘贴以下内容:
<!-- language: sh -->
sudo su -
cd /home/ec2-user
export LDFLAGS="$LDFLAGS -lrt"
export CMAKE_PREFIX_PATH=/home/ec2-user/hiphop/local
export HPHP_HOME=/home/ec2-user/hiphop/hiphop-php
export HPHP_LIB=/home/ec2-user/hiphop/hiphop-php/bin
ldconfig
alias hphp=/home/ec2-user/hiphop/hiphop-php/src/hphp/hphp
哦,我应该补充一点,您需要在要运行已编译脚本的服务器上安装 HipHop。所以考虑到所有这些,它可能不是你想要的。
如果你使用 CentOS 5.4,通过 yum 安装所有需要的软件包会更容易。只需先安装以下存储库:
HPHP:
rpm -ivh http://pkg.tag1consulting.com/hphp/x86_64/hphp-release-1.0-2.el5.noarch.rpm
EPEL:
rpm -ivh http://epel.osuosl.org/5/x86_64/epel-release-5-4.noarch.rpm
IUS:
rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1.0-8.ius.el5.noarch.rpm
安装前先卸载mysql和php
安装这些存储库后,您只需键入以下内容即可安装:
yum install hiphop-php
我读过 Amazon Linux 是基于 Fedora/CentOs 的,所以这可行吗?
https://github.com/facebook/hiphop-php/wiki/Installing-or-Building-HipHop-PHP-via-RPM-on-CentOS-5?
这个 git repo 允许你基于 Debian/Ubuntu 构建一个安装了 HipHop/HHVM 的 VM:
https://github.com/javer/hhvm-vagrant-vm
Vagrantfile 包含一个可以在 VM 或服务器上使用的脚本。但是,强烈建议首先使用 Vagrant VM 来查看 HipHop 是否适合您。