记录一下好不容易编译成功的HHVM,已经没有办法测试一下这性能怎么样,不过,看上去感觉好像还好,不算太差,不算太强。
由于Amazon Linux是基于CentOS的,又找到一个合适的编译好的版本,于是只好起一个Instance来编译HHVM。官方文档
https://github.com/facebook/hhvm/wiki/Building-and-installing-HHVM-on-Amazon-Linux-2014.03
注意
:适用于Amazon Linux 2014.03
执行
sudo yum -y update && \
sudo yum -y install \
autoconf \
automake \
binutils-devel \
boost-devel \
bzip2-devel \
chrpath \
cmake \
cpp \
curl-devel \
elfutils-libelf-devel \
expat-devel \
gcc-c++ \
gd-devel \
git \
jemalloc-devel \
libIDL-devel \
libc-client-devel \
libcap-devel \
libevent-devel \
libicu-devel \
libmcrypt-devel \
libmemcached-devel \
libtool \
libxml2-devel \
make \
memcached \
mysql-devel \
oniguruma-devel \
openldap-devel \
pam-devel \
patch \
pcre-devel \
readline-devel \
svn \
wget \
libxslt-devel \
ImageMagick-devel \
;
cd ~ && \
git clone git://github.com/facebook/hhvm.git && \
cd hhvm && \
git checkout HHVM-3.3.0 && \
git submodule update --init --recursive && \
export CMAKE_PREFIX_PATH=`pwd`/.. && \
cd ..
注意
: 修改了第三行的代码,官方的文档上有错。
wget https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb42_20130725oss_src.tgz && \
tar zxvf tbb42*.tgz && \
cd tbb42_20130725oss && \
cd src && \
make && \
cd .. && \
sudo mkdir -p /usr/include/serial && \
sudo cp -a include/serial/* /usr/include/serial/ && \
sudo mkdir -p /usr/include/tbb && \
sudo cp -a include/tbb/* /usr/include/tbb/ && \
sudo cp build/linux_intel64*/libtbb.so.2 /usr/lib64/ && \
sudo ln -s /usr/lib64/libtbb.so.2 /usr/lib64/libtbb.so && \
cd ..
git clone git://git.code.sf.net/p/libdwarf/code libdwarf && \
cd libdwarf/libdwarf && \
git checkout 2346f43f57f0ae768adffa55ea84b281d3aa71da && \
./configure && \
make && \
sudo cp libdwarf.a /usr/lib64/ && \
sudo cp libdwarf.h /usr/include/ && \
sudo cp dwarf.h /usr/include/ && \
cd ../..
wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz && \
tar zxvf glog-0.3.3.tar.gz && \
svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog && \
cd google-glog && \
./configure --prefix=/usr && \
make && \
sudo make install && \
cd ..
1.刷新库缓存
sudo ldconfig
2.编译和安装
cd hhvm && \
cmake . && \
make && \
sudo make install
PidFile = /var/run/hhvm/pid
Server {
IP = 127.0.0.1
Port = 9000
}
Log {
Level = Warning
AlwaysLogUnhandledExceptions = true
RuntimeErrorReportingLevel = 8191
UseLogFile = true
UseSyslog = false
File = /var/log/hhvm/error.log
Access {
* {
File = /var/log/hhvm/access.log
Format = %h %l %u % t \"%r\" %>s %b
}
}
}
Repo {
Central {
Path = /var/log/hhvm/.hhvm.hhbc
}
}
StaticFile {
FilesMatch {
* {
pattern = .*\.(dll|exe)
headers {
* = Content-Disposition: attachment
}
}
}
Extensions {
css = text/css
gif = image/gif
html = text/html
jpe = image/jpeg
jpeg = image/jpeg
jpg = image/jpeg
png = image/png
tif = image/tiff
tiff = image/tiff
txt = text/plain
}
}
MySQL {
TypedResults = false
}
Eval {
Jit = true
}
VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
pattern = ^(.*)$
to = index.php$1
qsa = true
}
}
}
}
一个启动的脚本如下所示
/usr/local/bin/hhvm --mode daemon --user web --config /etc/hhvm/server.hdf -vServer.Type=fastcgi -vServer.Port=9000
创建启动脚本hhvm.sh
#!/bin/bash
program=`/usr/local/bin/hhvm --mode daemon --user web --config /etc/hhvm/server.hdf -vServer.Type=fastcgi -vServer.Port=9000`
pidfile=/var/run/hhvm/pid
if [ `ps -o %mem,pid,comm,args -C hhvm | perl -ane 'if($F[0] > 75.0){print $F[1] . "\n";}' | while read i;do echo "$(date): Killing $i" >> /home/scripts/killlog.log;kill $i;done` ];then
$program &
fi
加入定时任务执行
crontab -e
加入一行
*/5 * * * * /root/hhvm.sh
修改原来的
fastcgi_pass unix:/tmp/php-cgi.sock;
为
fastcgi_pass 127.0.0.1:9000;
一个简单的完整Nginx配置示例所下
server
{
listen 80;
server_name blog.phodal.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/www/phodal
include wordpress.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fcgi.conf;
}
}
围观我的Github Idea墙, 也许,你会遇到心仪的项目