LEMP + HHVM Configuration

I’ve been reading about HHVM tonight, and I’d like to try it out myself. From what I’m gathering, it’s as simple as installing HHVM, and then configuring a server block to use it instead of php-fpm (then running “/usr/share/hhvm/”, right?). So before giving myself a headache, I thought I’d ask a preemptive question.

This is my current server block:

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;
	root /var/www/;
	index index.php index.html index.htm;
	location / {
			# try_files $uri $uri/ =404;
			try_files $uri $uri/ /wordpress$uri/ /index.php?q=$uri&$args;
	location ~ \.php$ {
			try_files $uri =404;
			fastcgi_split_path_info ^(.+\.php)(/.+)$;
			fastcgi_pass unix:/var/run/php5-fpm.sock;
			fastcgi_index index.php;
			include fastcgi_params;
	error_page 404 /404.html;
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;

I’ve only ever really configured these files once (relatively new to VPS, and I learned a LOT at once when I set this all up). That being said, I needed to use this line to get my permalinks with Wordpress to work properly:

try_files $uri $uri/ /wordpress$uri/ /index.php?q=$uri&$args;

I believe this was because I contained my Wordpress installation within a Wordpress folder (var/www/, rather than use the root. So my question is, how do I go about configuring HHVM with that in place? A lot of guides I’m seeing are saying to comment out all of the old server block code, which would undo my permalink alteration. Any ideas?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks for the config file, that should work. I tried this out just now, and got the following error:

Checking if Apache is installed
WARNING: Couldn't find Apache2 configuration paths, not configuring
Checking if Nginx is installed
Detected Nginx installation
Checking for custom Nginx configuration
WARNING: Detected clashing configuration. Look at /etc/nginx/hhvm.conf for information how to connect to the hhvm fastcgi instance.

I’m not loading any other config files to my knowledge, nor doing anything fancy, so I’m not sure what’s wrong here. Any idea what could cause this, and what I might do to remedy it?

Give this a whirl

server {
	listen 80;
	root /var/www/; 
	# No rewrite rules, just set the Wordpress directory as the root
	index index.php index.html;
	try_files $uri $uri/ /index.php?$args; 
	# Simplified Wordpress clean URL rewriting
	location ~ \.(hh|php)$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_param SCRIPT_FILENAME
		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_buffer_size 128k;
		fastcgi_buffers 256 16k;
		fastcgi_busy_buffers_size 256k;
		fastcgi_temp_file_write_size 256k;
		fastcgi_index index.php;
		include fastcgi_params;

This way all you should need to do is start up HHVM, give NGINX a reload and you’ll be good to go!