HHVM搭建胜过ZendPHP五六倍的PHPWeb服务器(高性能PHP虚拟机Hiphop)
HHVM搭建胜过ZendPHP五六倍的PHPWeb服务器(高性能PHP虚拟机Hiphop) 作者:余超 yuchao86@gmail.com我的测试环境是CentOS64位虚拟机如下:Linux localhost.localdomain 2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13 13:06:13 UTC 201
作者:余超 yuchao86@gmail.com
我的测试环境是CentOS64位虚拟机
如下:Linux localhost.localdomain 2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13 13:06:13 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
参照官方的安装方式,用官方提供的yum源进行安装,步骤如下:
Step1:设置好yum源
rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget -O /etc/yum.repos.d/hop5.repo http://www.hop5.in/yum/el6/hop5.repo
yum clean all
Step2:安装好基础环境包。。。比较多。。。
rpm -ivh ftp://rpmfind.net/linux/epel/beta/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
rpm -ivh ftp://rpmfind.net/linux/epel/beta/6/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
yum install git svn cpp make autoconf automake libtool patch memcached gcc-c++ cmake wget boost-devel mysql-devel pcre-devel gd-devel libxml2-devel expat-devel libicu-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel binutils-devel pam-devel elfutils-libelf-devel tbb-devel libdwarf-devel dbus-cxx-devel libunwind-devel php-mssql libtool
如果准备编译安装的话,装以下的包就能够搭建好编译环境,如果不像编译安装则略过
yum install -y boost.x86_64 \
boost-chrono.x86_64 \
boost-date-time.x86_64 boost-devel.x86_64 boost-filesystem.x86_64 boost-graph.x86_64 boost-graph-mpich2.x86_64 \
boost-graph-openmpi.x86_64 \
boost-iostreams.x86_64 boost-jam.x86_64 boost-locale.x86_64 boost-math.x86_64 boost-mpich2.x86_64 boost-mpich2-devel.x86_64 \
boost-mpich2-python.x86_64 \
boost-openmpi.x86_64 boost-openmpi-devel.x86_64 boost-openmpi-python.x86_64 boost-program-options.x86_64 \
boost-python.x86_64 \
boost-random.x86_64 boost-regex.x86_64 boost-serialization.x86_64 boost-signals.x86_64 boost-static.x86_64 \
boost-system.x86_64 \
boost-test.x86_64 boost-thread.x86_64 boost-timer.x86_64 boost-wave.x86_64 cpp.x86_64 curl.x86_64 \
gcc.x86_64 \
gcc-c++.x86_64 gcc-gfortran.x86_64 gcc-objc.x86_64 gcc-objc++.x86_64 gcc-plugin-devel.x86_64 \
glog.x86_64 \
glog-devel.x86_64 gmp.x86_64 gmp-devel.x86_64 gmp-static.x86_64 golang.x86_64 \
libcurl.x86_64 \
libcurl-devel.x86_64 libdwarf.x86_64 libdwarf-devel.x86_64 libdwarf-static.x86_64 libdwarf-tools.x86_64 \
libevent.x86_64 \
libevent-devel.x86_64 libgcc.x86_64 libgfortran.x86_64 libgfortran-static.x86_64 libgomp.x86_64 libmemcached.x86_64 \
libmemcached-devel.x86_64 \
libmpc.x86_64 libmpc-devel.x86_64 libmudflap.x86_64 libmudflap-devel.x86_64 libmudflap-static.x86_64 \
libobjc.x86_64 \
libquadmath.x86_64 libquadmath-devel.x86_64 libquadmath-static.x86_64 libstdc++.x86_64 libstdc++-devel.x86_64 libstdc++-static.x86_64 \
libtool.x86_64 \
libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64 lxc.x86_64 lxc-devel.x86_64 lxc-doc.x86_64 lxc-libs.x86_64 lxc-templates.x86_64 mpfr.x86_64 \
mpfr-devel.x86_64 \
nginx.x86_64 tbb.x86_64 tbb-devel.x86_64 tbb-doc.x86_64 \
如果这里安装 golang 包报错可以选择不安装这个包
Step3.安装hhvm
如果不是编译安装,只要执行
yum install hhvm
如果出现库路径错误,可以用下面的命令
yum install --skip-broken --setopt=protected_multilib=false hhvm
如果之前的库出现冲突,删除之前的库。
rpm -e boost-list*****
看到complete为止安装完毕
Step4.运行hhvm
运行php脚本直接执行
hhvm phpscript.php
hhvm会把php先编译成c++的代码再去运行
hhvm -m t phpscript.php
以服务器的方式运行:
hhvm -m s -c /etc/hhvm.conf
也可以使用hhvm以虚拟机的方式运行,这时候就相当于tomcat一样,配置文件可以指定监听一个端口,还有php网页文件存放的位置,会对指定位置下的php进行实时的编译,然后用nginx反向代理到这个端口就行了
运行方式:
hhvm -m daemon -c /etc/hhvm.conf
配置文件参照官方文档:
https://github.com/facebook/hiphop-php/wiki/Runtime-options
第三方扩展:
https://github.com/facebook/hiphop-php/wiki/HHVM-other-extension-share
摘自Stack Overflow的文章评论供大家参考:
After this question was asked, Facebook launched HipHop PHP,
which is probably the best-tested PHP compiler to date (seeing as it runs one of the world's 10 biggest websites)
Beyond that, googling "PHP compiler" turns up a number of 3rd party solutions:
http://www.roadsend.com/home/index.php?pageID=compiler
http://www.bambalam.se/bamcompile/
http://sourceforge.net/projects/binaryphp/
http://phalanger.codeplex.com/
更多推荐
所有评论(0)