Skip to content

Instantly share code, notes, and snippets.

@rubenve
Last active May 8, 2018 06:20
Show Gist options
  • Save rubenve/eab056273d227845862a to your computer and use it in GitHub Desktop.
Save rubenve/eab056273d227845862a to your computer and use it in GitHub Desktop.
Installing HHVM 3.2.0 on CentOS 6 with Plesk 11.5
# How to install the hhvm package using yum on CentOS 6.6 with Plesk 11.5
# Note that you can also install hhvm from source. For that check the official guides here:
# https://github.com/facebook/hhvm/wiki/Building-and-installing-HHVM-on-CentOS-6.6#13-install-ocaml
cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo
yum clean all
yum install hhvm
# For me this threw the following dependecy error:
# Error: Package: psa-libxml-proxy-2.7.8-13032215.x86_64 (@PSA_11_5_30-dist)
# Requires: libboost_program_options.so.5()(64bit)
# Removing: boost-program-options-1.41.0-27.el6.x86_64 (@base)
# libboost_program_options.so.5()(64bit)
# Updated By: boost-program-options-1.54.0-7.el6.x86_64 (hop5)
# Install boost first
wget http://www.hop5.in/yum/el6/boost-program-options-1.54.0-7.el6.x86_64.rpm
rpm -ivh boost-program-options-1.54.0-7.el6.x86_64.rpm
yum install hhvm
# Check if hhvm is working
hhvm --version
# Plesk 11.5 comes with Apache 2.2, so install mod_fastcgi
yum install libtool httpd-devel apr-devel apr
cd /opt
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -zxvf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6/
cp Makefile.AP2 Makefile
make top_dir=/usr/lib64/httpd
make install top_dir=/usr/lib64/httpd
# Have Apache load the module
vi /etc/httpd/conf.d/mod_fastcgi.conf
# Add this line
LoadModule fastcgi_module modules/mod_fastcgi.so
service httpd restart
# Make sure the module is loaded
apachectl -M |grep fastcgi
# Should output:
# fastcgi_module (shared)
# Syntax OK
# !Important: Disabe PHP support for the virtual host, otherwise the regular PHP handler will handle PHP requests.
# Next create a config file for HHVM:
vim /etc/hhvm/hhvm.hdf
# This is the content of my hhvm.hdf config file (note that the log level is set to Verbose, for production you can lower that)
Server {
Port = 9000
Type = fastcgi
FixPathInfo = true
}
Log {
Level = Verbose
UseLogFile = true
Header = true
File = /var/log/hhvm/error.log
Access {
* {
File = /var/log/hhvm/access.log
Format = %{X-Forwarded-For}i %l %u %t %v \"%r\" \"%{User-agent}i\" %>s %b %D
}
}
}
Eval {
Jit = true
EnableHipHopSyntax = true
}
# Start HHVM as a daemon
hhvm --config /etc/hhvm/hhvm.hdf --mode daemon
# Setup your vhost.conf. You can either do this in Plesk: Websites & Domains -> Web Server Settings -> Additional Directives for HTTP
<IfModule mod_fastcgi.c>
<FilesMatch \.php$>
SetHandler hhvm-php-extension
</FilesMatch>
<FilesMatch \.hh$>
SetHandler hhvm-hack-extension
</FilesMatch>
Alias /hhvm /hhvm
Action hhvm-php-extension /hhvm virtual
Action hhvm-hack-extension /hhvm virtual
FastCgiExternalServer /hhvm -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
</IfModule>
# ...or through the command-line
vim /var/www/vhosts/system/hhvm.example.com/conf/vhost.conf
<IfModule mod_fastcgi.c>
<FilesMatch \.php$>
SetHandler hhvm-php-extension
</FilesMatch>
<FilesMatch \.hh$>
SetHandler hhvm-hack-extension
</FilesMatch>
Alias /hhvm /hhvm
Action hhvm-php-extension /hhvm virtual
Action hhvm-hack-extension /hhvm virtual
FastCgiExternalServer /hhvm -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
</IfModule>
# Restart Apache
service httpd restart
# Test it: create a php file in your virtual host's document root, i.e. test.php
vim /var/www/vhosts/hhvm.example.com/test.php
# Add the following content to test.php:
<?php
echo defined('HHVM_VERSION')?'Using HHVM':'Not using HHVM';
# Finally open a webbrowser and navigate to the test.php file. It should return 'Using HHVM' if everything is working.
# If not then check the log files under /var/log/hhvm (make sure this directory exists!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment