Skip to content

Instantly share code, notes, and snippets.

@adamelso
Last active August 29, 2015 13:55
Show Gist options
  • Save adamelso/8729049 to your computer and use it in GitHub Desktop.
Save adamelso/8729049 to your computer and use it in GitHub Desktop.
Facebook HHVM, Vagrant, Ubuntu 13.10, Symfony2
<?php
// ./web/app_dev.php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1', 'fe80::1', '::1', // Symfony Defaults for Localhost
'192.168.80.8' // Vagrant Box IP
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
# ./etc/hhvm/config.hdf
PidFile = /var/hhvm/hhvm.pid
Server {
Host = hiphop.ntreg.com
Port = 80
SourceRoot = /vagrant/web
DefaultDocument = app.php
}
Log {
Level = Warning
NoSilencer = true
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
}
}
}
Repo {
Central {
Path = /var/hhvm/.hhvm.hhbc
}
}
#include "/usr/share/hhvm/hdf/static.mime-types.hdf"
StaticFile {
FilesMatch {
* {
pattern = .*\.(dll|exe)
headers {
* = Content-Disposition: attachment
}
}
}
Extensions : StaticMimeTypes
}
; ./etc/php5/conf.d/php.ini
short_open_tag = Off
output_buffering = On
max_execution_time = 60
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = Europe/London
# -*- mode: ruby -*-
# vi: set ft=ruby :
# ./Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "saucy64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.network :forwarded_port, guest: 80, host: 8090
config.vm.network :private_network, ip: "192.168.80.8"
nfs = (RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/)
config.vm.synced_folder ".", "/vagrant", :nfs => nfs
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1536"] # hhvm needs at least 1.2GB memory with its default config
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
end
config.vm.provision "shell", inline: <<-shell
echo "deb http://dl.hhvm.com/ubuntu saucy main" > /etc/apt/sources.list.d/hhvm.list
apt-get update
apt-get install hhvm -y --force-yes
sudo cp /vagrant/etc/hhvm/config.hdf /etc/hhvm/config.hdf
sudo cp /vagrant/etc/php5/conf.d/php.ini /etc/hhvm/php.ini
hhvm -m daemon -c /etc/hhvm/config.hdf
shell
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment