把PHP代码编译成C/C++代码,使你的php跑得更快
2016-02-01 00:00
645 查看
http://blog.163.com/lgh_2002/blog/static/4401752620113635721100/
FaceBook 发布了一款能将php代码转换为C++的工具,hiphop, 如果你的网站很大,类似新浪这样的大型门户,可以考虑。
目前已经在CentOS和ubuntu等Linux服务器上编译通过。
安装:
一、需要依赖的包
cmake 2.6 is the minimum version
g++/gcc 4.3 is the minimum version
Boost 1.37 is the minimum version
flex
bison
re2c
libmysql
libxml2
libmcrypt
libicu 4.2 is the minimum version
openssl
binutils
libcap
gd
zlib
tbb Intel's Thread Building Blocks
Oniguruma
libpcre
libexpat
libmemcached
下面的包需要在源代码的基础上打补丁
libcurl
src/third_party/libcurl.fb-changes.diff
libevent 1.4
src/third_party/libevent-1.4.13.fb-changes.diff OR src/third_party/libevent-1.4.14.fb-changes.diff
二、指定CMake的位置
export CMAKE_PREFIX_PATH=/home/user
三、编译
cd /home/user/dev
git clone git://github.com/facebook/hiphop-php.git
cd hiphop-php
git submodule init
git submodule update
export HPHP_HOME=`pwd`
export HPHP_LIB=`pwd`/bin
make
cmake .
据fackbook说,可以提高50%左右的性能,前提是php代码中不能含有eval这种很少用的方法。
四、使用hphp
环境设置:
cd .. # 进入hphp的根目录,源码的存放目录
export HPHP_HOME=`pwd`
export HPHP_LIB=`pwd`/bin
# if you followed the Ubuntu 9.10 instructions, you also need
export CMAKE_PREFIX_PATH=`/bin/pwd`/../
有若干种模式
1:直接编译为c++代码并执行
hphp/hphp test.php
2:编译到一个临时文件夹,并执行编译好的c++程序
hphp/hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program 这个根据你自己生成的运行
3:编译php为一个服务,并在指定端口运行
hphp/hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program -m server -p 8080
curl http://localhost:8080/test.php
sudo /tmp/hphp_p6vSsP/program -m daemon
参考:
https://github.com/facebook/hiphop-php/wiki/Running-HipHop
FaceBook 发布了一款能将php代码转换为C++的工具,hiphop, 如果你的网站很大,类似新浪这样的大型门户,可以考虑。
目前已经在CentOS和ubuntu等Linux服务器上编译通过。
安装:
一、需要依赖的包
cmake 2.6 is the minimum version
g++/gcc 4.3 is the minimum version
Boost 1.37 is the minimum version
flex
bison
re2c
libmysql
libxml2
libmcrypt
libicu 4.2 is the minimum version
openssl
binutils
libcap
gd
zlib
tbb Intel's Thread Building Blocks
Oniguruma
libpcre
libexpat
libmemcached
下面的包需要在源代码的基础上打补丁
libcurl
src/third_party/libcurl.fb-changes.diff
libevent 1.4
src/third_party/libevent-1.4.13.fb-changes.diff OR src/third_party/libevent-1.4.14.fb-changes.diff
二、指定CMake的位置
export CMAKE_PREFIX_PATH=/home/user
三、编译
cd /home/user/dev
git clone git://github.com/facebook/hiphop-php.git
cd hiphop-php
git submodule init
git submodule update
export HPHP_HOME=`pwd`
export HPHP_LIB=`pwd`/bin
make
cmake .
据fackbook说,可以提高50%左右的性能,前提是php代码中不能含有eval这种很少用的方法。
四、使用hphp
环境设置:
cd .. # 进入hphp的根目录,源码的存放目录
export HPHP_HOME=`pwd`
export HPHP_LIB=`pwd`/bin
# if you followed the Ubuntu 9.10 instructions, you also need
export CMAKE_PREFIX_PATH=`/bin/pwd`/../
有若干种模式
1:直接编译为c++代码并执行
hphp/hphp test.php
2:编译到一个临时文件夹,并执行编译好的c++程序
hphp/hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program 这个根据你自己生成的运行
3:编译php为一个服务,并在指定端口运行
hphp/hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program -m server -p 8080
curl http://localhost:8080/test.php
sudo /tmp/hphp_p6vSsP/program -m daemon
参考:
https://github.com/facebook/hiphop-php/wiki/Running-HipHop
相关文章推荐
- HipHop--php转换C++
- 为PHP开发C++扩展
- 为PHP开发C语言扩展
- 面对对象程序设计_task2_C++视频教程
- C++复习8
- 2011年第二届蓝桥杯(C/C++)预赛题目及个人答案(欢迎指正)
- C++类型向上转换的一种形式
- c语言:求圆周长、圆面积、圆球表面积、圆球体积、圆柱体积。
- 《C语言程序设计》指针篇<一>
- C++ Primer Summary
- libc++ hashtable 源码简析
- 值得推荐的C/C++框架和库
- 一起talk C栗子吧(第一百一十六回:C语言实例--线程同步之互斥量二)
- c++下基于windows socket的服务器客户端程序(基于UDP协议)
- 第三届蓝桥杯C/C++组第十题 取球游戏(博弈)
- 紫书第5章 C++STL
- C++builder 6的安装说明
- c语言:请编程序将“China”译成密码,分别用putchar和printf函数输出这5个字符。
- C++,笔试面试,使用C++编程,实现万年历
- c语言:用scanf函数输入数据,举例并分析错误原因