CentOS 6.5 安装 HHVM

  • 内容
  • 评论
  • 相关

一、CentOS 6.5 32位安装 HHVM:
安装:
yum -y install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum clean all
yum install hhvm
可能遇到的问题:
1.hhvm: error while loading shared libraries: liblcms2.so.2: cannot open shared object file: No such file or directory
yum install http://pkgrepo.linuxtech.net/el6/release/x86_64/liblcms2-2.4-1.el6.x86_64.rpm
2.其他相关文章
http://blog.csdn.net/ownfire/article/details/41366995
http://blog.linuxeye.com/396.html
http://blog.csdn.net/lxlmj/article/details/22283043
二、64位安装HHVM包:
安装hhvm
添加epel yum源
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
安装hhvm所需要的依赖包
yum -y install libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel mysql-devel \
libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel \
bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel \
libevent-devel libcurl-devel libmemcached-devel
添加gleez yum源(官方地址被墙)
rpm -Uvh http://blog.linuxeye.com/wp-content/uploads/2014/05/gleez-repo-6-0.el6.noarch.rpm
添加remi yum源
rpm -Uvh http://rpms.famillecollet.com/enterprise/6/remi/x86_64/remi-release-6.5-1.el6.remi.noarch.rpm
从remi安装hhvm依赖包
yum -y --enablerepo=remi install libwebp mysql mysql-devel mysql-lib
安装hhvm
yum -y --nogpgcheck install hhvm
查看hhvm版本号
hhvm --version
image
3. 配置hhvm
删除安装hhvm时创建的nginx用户
userdel -r nginx
修改hhvm目录权限为www
chown -R www.www /var/run/hhvm
chown -R www.www /var/log/hhvm
修改/usr/local/nginx/conf/nginx.conf使其中一段成为如下:
        location ~ .*\.(php|php5)?$  {
                fastcgi_pass   unix:/var/run/hhvm/sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
                }
service nginx reload
下载支持hhvm方式添加虚拟主机脚本 vhost_hhvm.sh
cd lnmp
wget http://blog.linuxeye.com/wp-content/uploads/2014/05/vhost_hhvm.sh
chmod +x vhost_hhvm.sh
配置hhvm修改/etc/hhvm/config.hdf,保持如下:
ResourceLimit {
  CoreFileSize = 0          # in bytes
  MaxSocket = 10000         # must be not 0, otherwise HHVM will not start
  SocketDefaultTimeout = 5  # in seconds
  MaxRSS = 0
  MaxRSSPollingCycle = 0    # in seconds, how often to check max memory
  DropCacheCycle = 0        # in seconds, how often to drop disk cache
}
Log {
  Level = Info
  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
    }
  }
}
MySQL {
  ReadOnly = false
  ConnectTimeout = 1000      # in ms
  ReadTimeout = 1000         # in ms
  SlowQueryThreshold = 1000  # in ms, log slow queries as errors
  KillOnTimeout = false
}
Mail {
  SendmailPath = /usr/sbin/sendmail -t -i
  ForceExtraParameters =
}
配置hhvm修改/etc/hhvm/server.ini,使内容保存如下:
; php options
pid = /var/run/hhvm/pid
; hhvm specific
;hhvm.server.port = 9001
hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
修改/etc/hhvm/php.ini,使内容保存如下:
hhvm.mysql.socket = /tmp/mysql.sock ;指定mysql.sock路径(hhvm默认路径sock路径是/var/lib/mysql/mysql.sock)
expose_php = 0 ;关闭头信息X-Powered-By (和hhvm.server.expose_hphp = false作用一样)
memory_limit = 400M
post_max_size = 50M
默认hhvm不提供php中类似disable_functions参数,如何禁用hhvm中shell_exec函数?(可选)
在/etc/hhvm/php.ini中追加如下:
hhvm.jit_enable_rename_function=true
auto_prepend_file= /home/wwwroot/default/disable_functions
新建/home/wwwroot/default/disable_functions,使该文件内容如下:
<?php
function __forbidden_function($name, $obj, $args, $data, &$done) {
  throw new Exception('Calling '.$name.' is forbidden.');
}
fb_intercept('shell_exec', '__forbidden_function');
配置service管理hhvm:
cd /etc/init.d/
rm -rf hhvm #官方默认脚本是以www运行,建议用我修改后的
wget http://blog.linuxeye.com/wp-content/uploads/2014/05/hhvm
chmod +x hhvm
chkconfig hhvm on
service hhvm restart
添加虚拟主机:
vhost_hhvm.sh #和lnmp添加虚拟主机一样
测试wordpress完美运行,且速度非常快;discuz后台正常,前台页面显示有点问题
参考:https://github.com/facebook/hhvm/wiki/HHVM-Pre-built-packages-for-Centos-6.5
安装时,这个rpm包是有很多的依赖:
因为依赖关系问题而跳过的软件包:
    OpenEXR-libs-1.6.1-8.1.el6.x86_64 来自 base
    boost-1.54.0-9.el6.x86_64 来自 gleez
    boost-atomic-1.54.0-9.el6.x86_64 来自 gleez
    boost-chrono-1.54.0-9.el6.x86_64 来自 gleez
    boost-context-1.54.0-9.el6.x86_64 来自 gleez
    boost-date-time-1.54.0-9.el6.x86_64 来自 gleez
    boost-devel-1.54.0-9.el6.x86_64 来自 gleez
    boost-filesystem-1.54.0-9.el6.x86_64 来自 gleez
    boost-graph-1.54.0-9.el6.x86_64 来自 gleez
    boost-iostreams-1.54.0-9.el6.x86_64 来自 gleez
    boost-locale-1.54.0-9.el6.x86_64 来自 gleez
    boost-log-1.54.0-9.el6.x86_64 来自 gleez
    boost-math-1.54.0-9.el6.x86_64 来自 gleez
    boost-program-options-1.54.0-9.el6.x86_64 来自 gleez
    boost-python-1.54.0-9.el6.x86_64 来自 gleez
    boost-random-1.54.0-9.el6.x86_64 来自 gleez
    boost-regex-1.54.0-9.el6.x86_64 来自 gleez
    boost-serialization-1.54.0-9.el6.x86_64 来自 gleez
    boost-signals-1.54.0-9.el6.x86_64 来自 gleez
    boost-system-1.54.0-9.el6.x86_64 来自 gleez
    boost-test-1.54.0-9.el6.x86_64 来自 gleez
    boost-thread-1.54.0-9.el6.x86_64 来自 gleez
    boost-timer-1.54.0-9.el6.x86_64 来自 gleez
    boost-wave-1.54.0-9.el6.x86_64 来自 gleez
    hhvm-3.5.0-4.el6.x86_64 来自 gleez
    ilmbase-1.0.1-6.1.el6.x86_64 来自 base
    inotify-tools-3.14-1.el6.x86_64 来自 epel
    lcms2-2.3-2.el6.x86_64 来自 epel
    libvpx-1.3.0-5.el6_5.x86_64 来自 base
    libyaml-0.1.3-4.el6_6.x86_64 来自 updates
yum install boost-1.54.0-9.el6.x86_64
源码安装:http://tomlog.com/tech/2012/12/21/build-hhvm.html
安装脚本:http://amh.sh/bbs/post-4874-1-1.htm