Page 1 of 1

HHVM template research thread

Posted: Sun Apr 26, 2015 2:50 pm
by zorrobyte
Greetings!

HHVM is a super fast PHP and HACK language JIT compiler which replaces the PHP runtime.It can often be 2x faster then PHP 5.6 with OpCache enabled: https://kinsta.com/blog/real-world-word ... -and-hhvm/

This is how you install it on Ubuntu:

Code: Select all

Ubuntu 12.04:
$ sudo add-apt-repository -y ppa:mapnik/boost
$ wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
$ echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
$ sudo apt-get update
$ sudo apt-get install -y hhvm


Ubuntu 14.04:
$ wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
$ echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
$ sudo apt-get update
$ sudo apt-get install -y hhvm
Install script:

Code: Select all

sudo /usr/share/hhvm/install_fastcgi.sh
Run HHVM at boot:

Code: Select all

sudo update-rc.d hhvm defaults
Use HHVM at the command line instead of PHP (optional)

Code: Select all

sudo /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
I took the advise in viewtopic.php?f=11&t=5830 and instead of modifying the default.tpl profile (which breaks phpmyadmin), but I copied (as phpmyadmin breaks if in default and I don't want default running HHVM):

/usr/local/vesta/data/templates/web/nginx/default.tpl --> /usr/local/vesta/data/templates/web/nginx/hhvm.tpl
/usr/local/vesta/data/templates/web/nginx/hhvm.stpl -> /usr/local/vesta/data/templates/web/nginx/hhvm.stpl

and then added the tweaks from https://github.com/facebook/hhvm/issues/3472

**Apache Config Guide**

https://github.com/facebook/hhvm/wiki/FastCGI says we need mod_proxy mod_proxy_fcgi, so:

Code: Select all

sudo a2enmod proxy_fcgi
(this enables mod_proxy automatically as a dependency)

cp /usr/local/vesta/data/templates/web/apache2/default.tpl /usr/local/vesta/data/templates/web/apache2/hhvm.tpl
cp /usr/local/vesta/data/templates/web/apache2/default.stpl /usr/local/vesta/data/templates/web/apache2/hhvm.stpl

Add

Code: Select all

	ProxyPass / fcgi://127.0.0.1:9000/%docroot%/
	# Or if you used a unix socket
	# ProxyPass / unix://var/run/hhvm/sock|fcgi://127.0.0.1:9000/path/to/your/www/root/goes/here/
	<Directory %docroot%>
		DirectoryIndex index.php
	</Directory>
To each hhvm.tpl & hhvm.stpl

You'll also want to:

Code: Select all

rm /etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf
As this file overrides the vhost config: https://github.com/facebook/hhvm/issues/3472

Now you can select your new HHVM template(s) in VestaCP under Packages or Host config!

Re: HHVM template research thread

Posted: Sun Apr 26, 2015 7:47 pm
by bestony
Good~!

Re: HHVM template research thread

Posted: Fri May 01, 2015 12:59 pm
by Yikmings
Great and thanks for sharing.

Re: HHVM template research thread

Posted: Sat Aug 29, 2015 5:42 pm
by estreetz
Hi,

I try your tutorial, it's work good with varnish
but i cannot use mod_rewrite on wordpress i got error 404
Did you have a idea ?

Thank You