==================测试环境redhat 6.0 64bit
cmake 2.6 is the minimum version
g++/gcc 4.3 is the minimum version
Boost 1.37 is the minimum version
libicu 4.2 is the minimum version
tbb Intel's Thread Building Blocks
===64bit ====https://github.com/facebook/hiphop-php zhengdlwb@....
https://github.com/facebook/hiphop-php/issues
http://groups.google.com/group/hiphop-php-dev/
http://blog.liubijian.com/hiphop-php-install.html
http://www.ooso.net/archives/543
https://github.com/facebook/hiphop-php/wiki/building-and-installing
http://www.inanu.net/post/386.html
http://www.iteye.com/topic/1112434
http://www.oschina.net/question/54100_10698
http://www.ooso.net/archives/545
https://github.com/facebook/hiphop-php/wiki/using-nginx-as-front-server-to-hiphop Using nginx as front server to HipHop
http://www.joomlagate.com/article/joomla-review/hiphop-php-speed-up-joomla-websites/ HipHop PHP 或可提高 Joomla 网站运行效率达 50%?
====32bit====https://github.com/metagoto/hiphop-php
http://www.linuxidc.com/Linux/2011-04/35270.htm
======================================说明
不支持绝对路径
编译yii报错
编译wordpress成功
禁用非常用命令,如eval()
静态资源js,css,图片可用二级域名或一级域名匹配后缀走nginx/apache
前端80nginx,php访问分发到hiphop-php的服务上
hphp --input-dir=/tmp/aa/ --keep-tempdir=1 --log=3
./program -m server -p 8081
http://192.168.1.95:8081/a/1.php
http://192.168.1.95:8081/a2/2.php
=================================== 问题
???1 .如何编译两个不同根下的目录
cp -avx /tmp/{a,a2} /tmp/aa/
cp -avx {/tmp/a,/tmp/a2} /tmp/aa/
hphp --input-dir /tmp/{a,a2} --keep-tempdir=1 --log=3 不成功
??? 2. YII编译报错 hphp --input-dir=/tmp/yii/ --keep-tempdir=1 --log=3 --force=1
[root@XEN208_MS_HIPHOP_95 tmp]# hphp --input-dir=/tmp/yii/ --keep-tempdir=1 --log=3
running hphp...
creating temporary directory /tmp/hphp_8EI4PF ...
parsing inputs...
Unable to stat file /tmp/yii/framework/gii/components/Pear/Text/Diff/Renderer/Text/Diff/Renderer.php
Unable to stat file /tmp/yii/framework/gii/components/Pear/Text/Diff/Text/Diff.php
Unable to stat file /tmp/yii/framework/gii/components/Pear/Text/Text/Diff.php
Unable to stat file /tmp/yii/framework/gii/components/Text/Diff.php
Unable to stat file /tmp/yii/framework/gii/components/Text/Diff/Renderer.php
Unable to stat file /tmp/yii/framework/gii/components/Text/Diff/Renderer/inline.php
Unable to stat file /tmp/yii/framework/test/PHPUnit/Runner/Version.php
Unable to stat file /tmp/yii/framework/test/PHPUnit/Autoload.php
Unable to stat file /tmp/yii/framework/test/PHPUnit/Extensions/SeleniumTestCase.php
Unable to stat file /tmp/yii/framework/vendors/TextHighlighter/Text/Text/Highlighter/Generator.php
Unable to stat file /tmp/yii/framework/vendors/TextHighlighter/Text/Console/Getopt.php
parsing inputs took 0'07" (7181 ms) wall time
pre-optimizing...
pre-optimizing took 0'00" (293 ms) wall time
inferring types...
inferring types took 0'01" (1003 ms) wall time
post-optimizing...
post-optimizing took 0'00" (377 ms) wall time
creating CPP files...
creating CPP files took 0'03" (3134 ms) wall time
saving code errors...
compiling and linking CPP files...
/tmp/hphp_8EI4PF/php/framework/db/schema/mysql/CMysqlSchema.cpp:
In member function \xe2\x80\x98double HPHP::c_CMysqlSchema::t_getserverversion()\xe2\x80\x99:\n/tmp/hphp_8EI4PF/php/framework/db/schema/mysql/CMysqlSchema.cpp:808
: \xe9\x94\x99\xe8\xaf\xaf\xef\xbc\x9a\xe2\x80\x98q_PDO___ATTR_SERVER_VERSION\xe2\x80\x99\xe5\x9c\xa8\xe6\xad\xa4\xe4\xbd\x9c\xe7\x94\xa8\xe5\x9f\x9f\xe4\xb8\xad\xe5\xb0\x9a\xe6\x9c\xaa\xe5\xa3\xb0\xe6\x98\x8e\nmake[2]: *** [CMakeFiles/program.dir/php/framework/db/schema/mysql/CMysqlSchema.cpp.o]
\xe9\x94\x99\xe8\xaf\xaf 1\nmake[1]: *** [CMakeFiles/program.dir/all] \xe9\x94\x99\xe8\xaf\xaf 2\nmake: *** [all] \xe9\x94\x99\xe8\xaf\xaf 2\n
compiling and linking CPP files took 7'06" (426610 ms) wall time
hphp failed
running hphp took 7'19" (439331 ms) wall time
=========>>>
官方解答:
open /tmp/hphp8EI4PF/php/framework/db/schema/mysql/CMysqlSchema.cpp
and replace q_PDO__ with q_PDO$$ and run make again .
known bug
================================编译 PHP 到 C++,Hiphop-PHP 有 5 种编译方法:
系统环境变量的设置
Hiphop-PHP 在运行前需要设置两个系统环境变量,分别是 $HPHP_HOME 和 $HPHP_LIB。对于这篇文章中的 RPM 包方式安装的 Hiphop-PHP,这两个环境变量应该这样设置:
export HPHP_HOME=/usr/lib64/hphp
export HPHP_LIB=/usr/lib64/hphp/bin
(1)编译并直接运行
hphp test.php
(2)将 PHP 编译到临时目录,手动执行
hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program (注意!在你的系统中,临时目录的目录名和我不相同,需要进入正确的目录。)
(3)将 PHP 编译到临时目录,启动程序并以 WEB SERVER 方式访问
hphp test.php --keep-tempdir=1 --log=3
/tmp/hphp_p6vSsP/program -m server
打开浏览器,输入 http://www.your.domain/test.php 访问。
你也可以让 Hiphop-PHP 运行于非 80 端口:
/tmp/hphp_p6vSsP/program -m server -p 8080
对于生产环境来说,我们希望 Hiphop-PHP 以守护进程方式运行:
/tmp/hphp_p6vSsP/program -m daemon
(4)运行时解析
hphpi -f test.php
这个就不太推荐了,不过可以作为 Debug 模式来用。
(5)以 WEB 方式运行时解析
hphpi -m daemon
在浏览器中访问 http://www.your.domain/test.php 来访问。
========================================性能对比
# time php t.php
simple 0.227
simplecall 0.277
simpleucall 0.282
simpleudcall 0.287
mandel 0.655
mandel2 0.841
ackermann(7) 0.273
ary(50000) 0.035
ary2(50000) 0.030
ary3(2000) 0.281
fibo(30) 0.897
hash1(50000) 0.069
hash2(500) 0.056
heapsort(20000) 0.170
matrix(20) 0.161
nestedloop(12) 0.378
sieve(30) 0.188
strcat(200000) 0.019
------------------------
Total 5.126
real 0m5.165s
user 0m5.016s
sys 0m0.049s
# time ./program
simple 0.003
simplecall 0.001
simpleucall 0.001
simpleudcall 0.001
mandel 0.291
mandel2 0.294
ackermann(7) 0.046
ary(50000) 0.016
ary2(50000) 0.010
ary3(2000) 0.183
fibo(30) 0.183
hash1(50000) 0.043
hash2(500) 0.037
heapsort(20000) 0.068
matrix(20) 0.040
nestedloop(12) 0.021
sieve(30) 0.041
strcat(200000) 0.006
------------------------
Total 1.284
real 0m1.743s
user 0m1.498s
sys 0m0.024s
===================================== 编译多个目录
/tmp/aa
/a/1.php
/a2/2.php
a/1.php
<?php
$a="a";
echo $a;
?>
a2/2.php
<?php
include("../a/1.php");
echo $a;
?>
hphp --input-dir=/tmp/aa/ --keep-tempdir=1 --log=3
./program -m server -p 8081
http://192.168.1.95:8081/a/1.php
http://192.168.1.95:8081/a2/2.php
======================================= 编译class
<?php
class a {
function func1()
{
echo("I'm func1 in A!<br/>");
}
function func2()
{
echo("I'm func2 in A!<br/>");
}
}
$b = new a();
$b->func1();
?>
#hphp test.php 编译并直接运行
#hphpi -f test.php 运行时解析
==========================================# hphp --help
HipHop Compiler for PHP Usage:
hphp <options> <inputs>
Options:
--help display this message
--version display version number
-t [ --target ] arg (=run) lint | analyze | php | cpp | sep-ext-cpp |
filecache | run (default)
-f [ --format ] arg lint: (none); 运行时解析 hphpi -f test.php
analyze: (none);
php: trimmed (default) | inlined | pickled |
typeinfo | <any combination of them by any
separator>;
cpp: cluster (default) | file | sys | exe |
lib;
run: cluster (default) | file
--cluster-count arg (=0) Cluster by file sizes and output roughly these
many number of files. Use 0 for no clustering.
--input-dir arg input directory 输入的目录(支持多个目录)
--program arg (=program) final program name to use
--args arg program arguments
-i [ --inputs ] arg input file names 输入的文件名
--input-list arg file containing list of file names, one per 包含文件的文件名列表,每行一个
line
--include-path arg a list of full paths to search for files being
included in includes or requires but cannot be
found assuming relative paths
--module arg directories containing all input files 包含所有的输入文件的目录
--exclude-dir arg directories to exclude from the input
--fmodule arg same with module, except no exclusion checking
is performed, so these modules are forced to
be included
--ffile arg extra PHP files forced to include without 被迫额外的PHP文件,包括不排除检查
exclusion checking
--exclude-file arg files to exclude from the input, even if 排除输入的文件,即使解析按需发现
parse-on-demand finds it
--exclude-pattern arg regex (in 'find' command's regex command line
option format) of files or directories to
exclude from the input, even if
parse-on-demand finds it
--exclude-static-pattern arg regex (in 'find' command's regex command line
option format) of files or directories to
exclude from static content cache
--exclude-static-dir arg directories to exclude from static content 目录排除静态内容缓存
cache
--exclude-static-file arg files to exclude from static content cache 文件排除从静态内容缓存
--cfile arg extra static files forced to include without 额外的静态文件,迫使包括不排除检查
exclusion checking
--cmodule arg extra directories for static files without 不排除签静态文件的额外目录
exclusion checking
--parse-on-demand arg (=1) whether to parse files that are not specified 不从命令行中指定的文件是否解析
from command line
--branch arg SVN branch
--revision arg SVN revision
-o [ --output-dir ] arg output directory
--output-file arg output file 输出文件
--sync-dir arg Files will be created in this directory first, 文件将在此目录中创建的第一个,然后同步输出目录覆盖相同的文件。增量编译和构建大。
then sync with output directory without
overwriting identical files. Great for
incremental compilation and build.
--optimize-level arg (=1) optimization level 优化级别
--gen-stats arg (=0) whether to generate code errors
-k [ --keep-tempdir ] arg (=0) whether to keep the temporary directory 是否保留临时目录
--db-stats arg database connection string to save code
errors: <username>:<password>@<host>:<port>/<d
b>
--no-type-inference arg (=0) turn off type inference for C++ code 关闭C + +代码生成的类型推断
generation
--no-min-include arg (=0) turn off minimium include analysis when target 关闭minimium包括分析时的目标是“分析”
is "analyze"
--no-meta-info arg (=0) do not generate class map, function jump table 不生成类图,函数跳转表和宏,在生成代码时,用于演示目的
and macros when generating code; good for demo
purposes
-c [ --config ] arg config file name
--config-dir arg root directory configuration is based on (for 根目录配置的基础上(例如,排除的目录可能会在配置中的相对路径。
example, excluded directories may be relative
path in configuration.
-v [ --config-value ] arg individual configuration string in a format of 个人配置字符串名称=值,名称可以是任何有效的配置配置文件的格式
name=value, where name can be any valid
configuration for a config file
-l [ --log ] arg (=-1) -1: (default); 0: no logging; 1: errors only; log级别
2: warnings and errors; 3: informational as
well; 4: really verbose.
--force arg (=1) force to ignore code generation errors and 强制忽略代码生成错误并继续编译
continue compilations
--file-cache arg if specified, generate a static file cache 如果指定的话,产生与此文件名的静态文件缓存
with this file name
--rtti-directory arg the directory of rtti profiling data RTTI分析数据的目录
--java-root arg (=php) the root package of generated Java FFI classes
--generate-ffi arg (=0) generate ffi stubs
--dump arg (=0) dump the program graph 转储程序图
--docjson arg Filename to generate a JSON file for PHP docs 文件名生成一个JSON的PHP文件文件
--coredump arg (=0) turn on coredump
--nofork arg (=0) forking is needed for large compilation to 分叉是需要大量的编译之前的g ++编译释放内存。关闭分叉可以帮助gdb调试。
release memory before g++compilation. turning
off forking can help gdb debugging.
--fl-annotate arg (=0) Annote emitted source with compiler file-line Annote编译器文件行信息的排放源
info
--opts arg (=none) Set optimizations to enable/disable 设置启用/禁用的优化
--ppp arg Preprocessed partition configuration. To speed
up distcc compilation, bin/ppp.php can
pre-compute better partition between different
.cpp files according to preprocessed file
sizes, instead of original file sizes
(default). Run bin/ppp.php to generate an HDF
configuration file to specify here.
--compiler-id display the git hash for the compiler id 显示git的编译器ID哈希
--taint-status check if the compiler was built with taint 检查如果编译器是内置的污点启用
enabled
=========================== 安装配置(未完全整理,仅供参考) 原则:碰到哪个软件本版太底或没安装,安装后继续
http://www.iteye.com/topic/1112434
yum -y install git cmake pcre-devel libmcrypt-devel mysql-devel gd-devel libxml2-devel libcap-devel binutils-devel flex bison expat-devel patch gcc44 gcc44-c++ gcc gcc-c++ bzip2 bzip2-devel memcached openldap openldap-devel readline-devel libc-client-devel pam-devel wget ncurses-devel
安装注意事项
编译的时候碰到的问题很多,但是基本上都是按照wiki上的步骤进行的。我觉得比较重要的几点:
wiki上的Required Packages包包列表都要检查一遍,比如版本号,是否安装过,像binutils-dev这种就很容易忽略
版本符合的话,直接用yum安装这些包就可以了
wiki上有类似Boost 1.37 is the minimum version字样,说明开发者可能就是在这个版本下开发的,我试了下最新版本的boost,编译到后来反而出错
如果yum上没有符合版本的lib库,可以手动编译,但是编译时建议就放在自己的home下,比如:
DE>./configure --prefix=/home/userDE>
tbb Intel’s Thread Building Blocks这个包有些麻烦,记得按照wiki上说的步骤安装
export CMAKE_PREFIX_PATH=/root
To build HipHop, use the following:
Linux:
cd /root/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
cmake .
.....
make
cd libmemcached-0.48
./configure
make install
cd ..
cd libevent-1.4.14-stable
cp ../hiphop-php/src/third_party/libevent-1.4.14.fb-changes.diff .
patch < libevent-1.4.14.fb-changes.diff
./configure
make install
cd ..
yum install libXpm
rpm -Uvh gd-2.0.35-10.el6.x86_64.rpm
wget wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure
make
make install
tar jxvf curl-7.20.0.tar.bz2
cd curl-7.20.0
cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff .
patch -p1 < libcurl.fb-changes.diff
./configure
make
make install
wget http://download.icu-project.org/files/icu4c/4.6.1/icu4c-4_6_1-src.tgz
cd icu/source
tar xvzf icu4c-4_6_1-src.tgz
./configure
make
make install
cd /tmp/rpm
###rpm -Uvh --force *.rpm --nodeps
rpm -Uvh --force *.rpm
wget "http://www.threadingbuildingblocks.org/uploads/77/142/2.2/tbb22_20090809oss_src.tgz"
tar xvzf tbb22_20090809oss_src.tgz
cd tbb22_20090809oss
gmake
cp -Rp include/tbb/ /usr/include/
cp ./build/*_release/*.so /usr/lib/
cp ./build/*_release/*.so.2 /usr/lib/
ldconfig
rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum install mcrypt.x86_64 libmcrypt-devel.x86_64
wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.2.tar.gz
或者下载地址http://www.google.com.hk/url?sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F%2Fwww.163disk.com%2Ffileview_273358.html&rct=j&q=onig-5.9.2.tar.gz&ei=DBJeTtehKovRmAX_w6Qy&usg=AFQjCNHaI9mOmm5o-BlJEAian2e9bKsYJw&cad=rjt
./configure
make
make install
yum install jemalloc-devel.x86_64 jemalloc.x86_64
yum install libc-client2007.x86_64
wget http://php.webtutor.pl/wp-content/uploads/2011/04/libcclient2007-devel.tar.gz
cp -r imap /usr/local/include/
cp /usr/lib/libc-client.so.2007 /usr/local/lib/libc-client.so
------------------ make 报错:
Linking CXX static library ../../bin/libhphp_analysis.a
[ 88%] Built target hphp_analysis
Scanning dependencies of target hphp
[ 88%] Building CXX object src/hphp/CMakeFiles/hphp.dir/main.cpp.o
Linking CXX executable hphp
/usr/bin/ld: warning: libcrypto.so.6, needed by /usr/local/lib/libc-client.so, m ay conflict with libcrypto.so.10
/usr/bin/ld: warning: libssl.so.6, needed by /usr/local/lib/libc-client.so, may conflict with libssl.so.10
../../bin/libhphp_runtime.a(ext_image.cpp.o): In function `HPHP::f_imagecreatefr omstring(HPHP::String const&)':
ext_image.cpp:(.text+0x70e7): undefined reference to `gdImageCreateFromJpegCtx'
../../bin/libhphp_runtime.a(ext_image.cpp.o): In function `HPHP::_php_image_conv ert(HPHP::String const&, HPHP::String const&, int, int, int, int)':
ext_image.cpp:(.text+0x77f9): undefined reference to `gdImageCreateFromJpeg'
../../bin/libhphp_runtime.a(ext_image.cpp.o): In function `HPHP::_php_image_crea te_from(HPHP::String const&, int, int, int, int, int, char*, gdImageStruct* (*)( ), gdImageStruct* (*)())':
ext_image.cpp:(.text+0x82e6): undefined reference to `gdImageCreateFromJpeg'
../../bin/libhphp_runtime.a(ext_image.cpp.o): In function `HPHP::f_imagecreatefr omjpeg(HPHP::String const&)':
ext_image.cpp:(.text+0x8b98): undefined reference to `gdImageCreateFromJpegCtx'
ext_image.cpp:(.text+0x8ba1): undefined reference to `gdImageCreateFromJpeg'
../../bin/libhphp_runtime.a(ext_image.cpp.o): In function `HPHP::f_imagejpeg(HPH P::Object const&, HPHP::String const&, int)':
ext_image.cpp:(.text+0x196ad): undefined reference to `gdImageJpegCtx'
../../bin/libhphp_runtime.a(ext_imagesprite.cpp.o): In function `HPHP::c_ImageSp rite::t_output(HPHP::String const&, HPHP::String const&, int)':
ext_imagesprite.cpp:(.text+0x4d29): undefined reference to `gdImageJpegPtr'
../../bin/libhphp_runtime.a(ext_imagesprite.cpp.o): In function `HPHP::ImageSpri te::Image::load_data_to_gd(int, void const*)':
ext_imagesprite.cpp:(.text+0x536e): undefined reference to `gdImageCreateFromJpe gPtr'
collect2: ld 返回 1
make[2]: *** [src/hphp/hphp] 错误 1
make[1]: *** [src/hphp/CMakeFiles/hphp.dir/all] 错误 2
make: *** [all] 错误 2
删除CMakeCache.txt,重新cmake .
yum install python-devel.x86_64
--------------------- gd 安装
mkdir /usr/local/modules
#jpeg目录
mkdir /usr/local/modules/jpeg6
mkdir /usr/local/modules/jpeg6/bin
mkdir /usr/local/modules/jpeg6/lib
mkdir /usr/local/modules/jpeg6/include
mkdir /usr/local/modules/jpeg6/man
mkdir /usr/local/modules/jpeg6/man/man1
a.zlib (看来zlib停止升级了,到现在还是2005年发布的一个东东)
# wget http://www.zlib.net/zlib-1.2.5.tar.gz //下载
# tar zxvf zlib-1.2.5.tar.gz //解压
# cd zlib-1.2.5 //改变目录
# CFLAGS=”-O3 -fPIC” ./configure //使用64位 的方法进行编译 (一般只需要./configure)
# make
# make install
b.FreeType
# wget http://downloads.sourceforge.net/freetype/freetype-2.3.5.tar.gz?modtime=1183336047&big_mirror=0 //下载
# tar zxvf freetype-2.3.5.tar.gz //解压
# cd freetype-2.3.5 //改变目录
# ./configure -prefix=/usr/local/modules/freetype //配置
# make //编译
# make install //安装
c.Libpng
# wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.8-config.tar.gz?download //下载
# tar zxvf libpng-1.2.8-config.tar.gz //解压
# cd libpng-1.2.8-config //改变目录
注意:首先看有没有装libtool (whereis libtool),没有就需要yum install libtool.
# ./configure //配置
# make //编译
# make install //安装
64位的机器这样搞
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure –enable-shared –enable-static
make
make install
d.jpeg
# wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz //下载
# tar jpegsrc.v8b.tar.gz //解压
# cd jpeg-8b //改变目录
# ./configure -prefix=/usr/local/modules/jpeg6 -enable-shared -enable-static //配置
# make //编译
# make install //安装
e.GD
# wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz //下载
# tar xzvf gd-2.0.33.tar.gz //解压
# cd gd-2.0.33 //改变目录
# ./configure -prefix=/usr/local/gd -with-jpeg=/usr/local/modules/jpeg6 -with-png=/usr/local/libpng -with-zlib -with-freetype=/usr/local/modules/freetype //配置
# make //编译
# make install //安装
cp -rf libgd.so libgd.so.2 libgd.so.2.0.0 /usr/local/lib64/
cp -rf libgd.so libgd.so.2 libgd.so.2.0.0 /usr/lib64/
cp -rf libgd.so libgd.so.2 libgd.so.2.0.0 /usr/lib/
/usr/bin/ld: warning: libcrypto.so.6, needed by /usr/local/lib/libc-client.so, may conflict with libcrypto.so.10
/usr/bin/ld: warning: libssl.so.6, needed by /usr/local/lib/libc-client.so, may conflict with libssl.so.10
[100%] Built target test
yum whatprovides "*/*libcrypto.so*"
经查,发现是运行机器的libcrypto.so版本太高,是libcrypto.so.6,而ldd显示nginx依赖的是libcrypto.so.4
于是,在对应的/lib64目录下建个libcrypto.so.4的软链接就可以了
/usr/bin/ld: warning: libcrypto.so.10, needed by /usr/lib64/mysql/libmysqlclient_r.so, may conflict with libcrypto.so.6
/usr/bin/ld: warning: libcrypto.so.10, needed by /usr/lib64/mysql/libmysqlclient_r.so, may conflict with libcrypto.so.6