CentOS 7 (HHVM only support 64-bit) under the HHVM nginx environment, so far CentOS 7 has not HHVM RPM installation package, so the source code compiled. Before installing the HHVM, it is strongly recommended that you install the complete LNMP (including Nginx, PHP, MySQL) using the LNMP one-click installation package, in which case we can configure each virtual host on the same server. If on the same server have www.111cn.net run on PHP, another website blog.linuxeye.com can choose to run in HHVM, and can switch freely with PHP or HHVM, simply modify the virtual host configuration file.
Installation steps:
1. Install the complete LNMP, refer to "LNMP One key installation package"
2. Install HHVM
RPM-UVH http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
Yum-y install git mariadb-devel curl-devel expat-devel libpng-devel psmisc binutils-devel\
Boost-devel libmcrypt-devel libmemcached-devel jemalloc-devel libevent-devel sqlite-devel\
Libxslt-devel libicu-devel tbb-devel libzip-devel bzip2-devel openldap-devel
Elfutils-libelf-devel libdwarf-devel libcap-devel libyaml-devel libedit-devel lz4-devel\
Libvpx-devel unixodbc-devel libgmp-devel libpng-devel imagemagick-devel curl-devel
CD LNMP/SRC
wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
Tar xvzf glog-0.3.3.tar.gz
CD glog-0.3.3
./configure
Make && make install
Cd..
wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.5.tar.gz
Tar xvzf onig-5.9.5.tar.gz
CD onig-5.9.5
./configure
Make && make install
Cd..
git clone https://github.com/facebook/hhvm-b master HHVM--recursive
CD HHVM
./configure
# # Use newer ImageMagick from Remi
RPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# # Remove the obsolete ImageMagick version
Yum-y Remove ImageMagick
Yum-y Install imagemagick-last*--enablerepo=remi
cmake-d libmagickwand_include_dirs= "/usr/include/imagemagick-6" \
-D libodbc_include_dirs= "/usr/lib64"-D libodbc_libraries= "/usr/lib64" \
-D libvpx_include_dirs= "/usr/lib64"-D libxslt_include_dir= "/usr/lib64" \
-D libxslt_libraries= "/usr/lib64/libxslt.so"-D libmagickwand_libraries= "/usr/lib64/libmagickwand-6.q16.so" \
-D libmagickcore_libraries= "/usr/lib64/libmagickcore-6.q16.so".
Make-j2 #利用cpu多核编译加快速度, 2 for nuclear number, single core without-j2, see CPU core: Cat/proc/cpuinfo | grep Processor | Wc-l
Note: The compilation process is very consuming system resources, it is possible to report insufficient memory to cause the compilation interrupt, the following error:
[30%] Building CXX Object THIRD-PARTY/THRIFT/CMAKEFILES/HPHP_THRIFT.DIR/THRIFT/LIB/CPP/ASYNC/TEVENTTASK.CPP.O
C + +: Internal compiler error:killed (program Cc1plus)
Please submit a full bug,
With preprocessed source if appropriate
After compiling, perform the following command to install:
Make install
After the installation is successful, print out the HHVM version:
HHVM--version
HipHop VM 3.4.0-dev (rel)
Compiler:heads/master-0-g0b46339509ebd9612623d52c296fdcc8e6f93dff
Repo schema:d8dcfe0a4feda06dea7087bd82b55ef19217b170
Extension api:20140829
3. Configure HHVM
Create and modify HHVM directory permissions
Mkdir/etc/hhvm/var/run/hhvm/var/log/hhvm
Chown-r WWW.WWW/VAR/RUN/HHVM/VAR/LOG/HHVM
Modify the/usr/local/nginx/conf/nginx.conf so that one paragraph becomes as follows:
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
method to add HHVM virtual host: Perform vhost_hhvm.sh
CD LNMP
wget http://blog.linuxeye.com/wp-content/uploads/2014/05/vhost_hhvm.sh
chmod +x vhost_hhvm.sh
Create the HHVM configuration file/ETC/HHVM/CONFIG.HDF and keep the following:
Resourcelimit {
corefilesize = 0 # in bytes
Maxsocket = 10000 # must is not 0, otherwise hhvm'll not start
Socketdefaulttimeout = 5 # in seconds
Maxrss = 0
maxrsspollingcycle = 0 # seconds, how often to check max memory
dropcachecycle = 0 # 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 =
}
Configure HHVM to modify the/etc/hhvm/server.ini to keep the following:
; 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
Modify/etc/hhvm/php.ini Specify Mysql.sock path (hhvm default path sock path is/var/lib/mysql/mysql.sock)
Hhvm.mysql.socket =/tmp/mysql.sock
expose_php = 0; Turn off header information x-powered-by (same as hhvm.server.expose_hphp = False)
Memory_limit = 400M
Post_max_size = 50M
Add power-on self-starter script
The contents of the/etc/systemd/system/hhvm.service document are as follows:
[Unit]
DESCRIPTION=HHVM HipHop Virtual Machine (fcgi)
[Service]
EXECSTART=/USR/LOCAL/BIN/HHVM--mode daemon--user www--config/etc/hhvm/server.ini\
--config/etc/hhvm/php.ini--CONFIG/ETC/HHVM/CONFIG.HDF
[Install]
Wantedby=multi-user.target
Manage HHVM Services
Systemctl Enable HHVM #开机自启动
Systemctl Start HHVM #启动hhvm
Systemctl Status Hhvm #查看hhvm状态