In analogy to the article of the hiphop-php.com site, I’ll try to give you a tutorial on how to run Drupal on HHVM
Installing HHVM
For the sake of this case-study, I used a Vagrant Ubuntu “Precise” 12.04 as my linux distribution. Also, to not screw up my local development machine, I’ll be using disposable virtual boxes.
Installing VirtualBox
https://www.virtualbox.org/wiki/Downloads Download and install the appropriate version of VirtualBox for your machine
Installing Vagrant
http://vagrantup.com/ Download and install the appropriate version of Vagrant for your machine
Downloading and Installing Precise64
cd ~/
git clone --recursive --branch 7.x-1.x http://git.drupal.org/project/vagrant.git
cd vagrant
vagrant box add base http://files.vagrantup.com/precise64.box
vagrant up
sudo nano /etc/hosts
# add
# 33.33.33.10 drupal.vbox.local dev-site.vbox.local
vagrant ssh
# Update our packages
sudo apt-get update
sudo apt-get upgrade
exit
# After updates, run chef again
vagrant provision
Installing hiphop-php
cd ~/vagrant
vagrant ssh
sudo add-apt-repository "deb http://dl.hiphop-php.com/ubuntu precise main"
# no sources are present in hiphops repository, so remove them
sudo add-apt-repository --remove "deb-src http://dl.hiphop-php.com/ubuntu"
sudo apt-get update
sudo apt-get install hiphop-php -y --force-yes
exit
Create a config file
cd ~/vagrant
vagrant ssh
sudo mkdir /var/log/hhvm
sudo chmod 777 /var/log/hhvm/
sudo nano /etc/hhvm.hdf
Add the following snippet and save the file (/etc/hhvm.hdf)
Server {
Port = 8000
SourceRoot = /vagrant/public/drupal.vbox.local/www/
}
Eval {
Jit = true
}
Log {
Level = Error
UseLogFile = true
File = /var/log/hhvm/error.log
Access {
* {
File = /var/log/hhvm/access.log
Format = %h %l %u %t \"%r\" %>s %b
}
}
}
VirtualHost {
* {
Pattern = .*
RewriteRules {
dirindex {
pattern = ^/(.*)/$
to = $1/index.php
qsa = true
}
}
}
}
StaticFile {
FilesMatch {
* {
pattern = .*\.(dll|exe)
headers {
* = Content-Disposition: attachment
}
}
}
Extensions {
css = text/css
gif = image/gif
html = text/html
jpe = image/jpeg
jpeg = image/jpeg
jpg = image/jpeg
png = image/png
tif = image/tiff
tiff = image/tiff
txt = text/plain
}
}
Start the webserver
cd ~/vagrant
vagrant ssh
# Adding some debug modes
sudo hhvm --config /etc/hhvm.hdf --user vagrant --mode daemon -v "Log.Level=Verbose" -v "Log.NoSilencer=on" -v "Log.Header=on"
tail -f /var/log/hhvm/error.log
- Go to http://drupal.vbox.local:8000/index.php in your browser
- You can see a couple of errors in the terminal but none of them really are significant.
[Fri Nov 30 12:07:27 2012] [hphp] [2544:7fe6eaf40dc0:0:000015] [] admin server started
[Fri Nov 30 12:07:27 2012] [hphp] [2544:7fe6eaf40dc0:0:000016] [] all servers started
[Fri Nov 30 12:07:27 2012] [hphp] [2544:518f3700:0:000001] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:27 2012] [hphp] [2544:518f3700:0:000002] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:27 2012] [hphp] [2544:518f3700:0:000003] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:30 2012] [hphp] [2544:5254c700:0:000001] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:30 2012] [hphp] [2544:5254c700:0:000002] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:30 2012] [hphp] [2544:5254c700:0:000003] [] perf_event_open failed with: No such file or directory
[Fri Nov 30 12:07:30 2012] [hphp] [2544:5254c700:1:000001] [] receiving index.php
[Fri Nov 30 12:07:30 2012] [hphp] [2544:5254c700:1:000002] [7fe6e4d5f4c0:7fe6e4d5f445:7fe6e4d62bab:7fe6e4d5810e:7fe6e4d581b2:b0d80d:114c70b:1154cd6:1359eab:d814db:d390b5:d391e8:d3943e:d39e5e:d3a064:c4af2e:b08ffb:b1ae95:b7fdc0:c14c9c:c02c06:c0529e:f9e1ca:f9e3d9:7fe6e83f7e9a:7fe6e4e1b4bd] Core dumped: Aborted
So I went looking for errors and found the following in /tmp/stacktrace-PID.log
Host: precise64
ProcessID: 2544
ThreadID: 5254c700
ThreadPID: 2553
Name: unknown program
Type: Aborted
URL: /index.php
ThreadType: Web Request
Server: drupal.vbox.local:8000
# 0 ?? at hhvm:0
# 1 killpg at /lib/x86_64-linux-gnu/libc.so.6:0
# 2 raise at /lib/x86_64-linux-gnu/libc.so.6:0
# 3 abort at /lib/x86_64-linux-gnu/libc.so.6:0
# 4 __uselocale at /lib/x86_64-linux-gnu/libc.so.6:0
# 5 __assert_fail at /lib/x86_64-linux-gnu/libc.so.6:0
# 6 ?? at hhvm:0
# 7 ?? at hhvm:0
# 8 HPHP::c_PDO::t_prepare(HPHP::String const&, HPHP::Array const&) at hhvm:0
# 9 HPHP::tg_3PDO_prepare(HPHP::VM::ActRec*) at hhvm:0
# 10 void HPHP::VMExecutionContext::dispatchImpl<4>(int) at hhvm:0
# 11 HPHP::VMExecutionContext::dispatch() at hhvm:0
# 12 HPHP::VMExecutionContext::enterVMWork(HPHP::VM::ActRec*) at hhvm:0
# 13 HPHP::VMExecutionContext::enterVM(HPHP::TypedValue*, HPHP::VM::ActRec*, HPHP::VM::ExtraArgs*) at hhvm:0
# 14 HPHP::VMExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::VM::Func const*, HPHP::Array const&, HPHP::ObjectData*, HPHP::VM::Class*, HPHP::VM::VarEnv*, HPHP::StringData*, HPHP::VM::Unit*) at hhvm:0
# 15 HPHP::VMExecutionContext::invokeUnit(HPHP::TypedValue*, HPHP::VM::Unit*) at hhvm:0
# 16 HPHP::eval_invoke_file_hook(HPHP::Variant&, HPHP::String const&, bool, HPHP::LVariableTable*, char const*) at hhvm:0
# 17 HPHP::invoke_file(HPHP::String const&, bool, HPHP::LVariableTable*, char const*) at hhvm:0
# 18 HPHP::include_impl_invoke(HPHP::String const&, bool, HPHP::LVariableTable*, char const*) at hhvm:0
# 19 HPHP::hphp_invoke(HPHP::ExecutionContext*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, HPHP::Array const&, HPHP::VRefParamValue const&, std::basic_string<char, std::char_traits<char>, std::$
# 20 HPHP::HttpRequestHandler::handleRequest(HPHP::Transport*) at hhvm:0
# 21 HPHP::LibEventWorker::doJob(boost::shared_ptr<HPHP::LibEventJob>) at hhvm:0
# 22 HPHP::JobQueueWorker<boost::shared_ptr<HPHP::LibEventJob>, true, false>::start() at hhvm:0
# 23 HPHP::AsyncFuncImpl::threadFuncImpl() at hhvm:0
# 24 HPHP::AsyncFuncImpl::ThreadFunc(void*) at hhvm:0
# 25 start_thread at /lib/x86_64-linux-gnu/libpthread.so.0:0
# 26 __clone at /lib/x86_64-linux-gnu/libc.so.6:0
PHP Stacktrace:
#0 PDO->prepare() called at [/vagrant/public/drupal.vbox.local/www/includes/database/database.inc:464]
#1 DatabaseConnection->prepareQuery() called at [/vagrant/public/drupal.vbox.local/www/includes/database/database.inc:663]
#2 DatabaseConnection->query() called at [/vagrant/public/drupal.vbox.local/www/includes/database/database.inc:2318]
#3 db_query() called at [/vagrant/public/drupal.vbox.local/www/includes/cache.inc:357]
#4 DrupalDatabaseCache->getMultiple() called at [/vagrant/public/drupal.vbox.local/www/includes/cache.inc:338]
#5 DrupalDatabaseCache->get() called at [/vagrant/public/drupal.vbox.local/www/includes/cache.inc:56]
#6 cache_get() called at [/vagrant/public/drupal.vbox.local/www/includes/bootstrap.inc:902]
#7 variable_initialize() called at [/vagrant/public/drupal.vbox.local/www/includes/bootstrap.inc:2403]
#8 _drupal_bootstrap_variables() called at [/vagrant/public/drupal.vbox.local/www/includes/bootstrap.inc:2180]
#9 drupal_bootstrap() called at [/vagrant/public/drupal.vbox.local/www/includes/bootstrap.inc:2301]
#10 _drupal_bootstrap_page_cache() called at [/vagrant/public/drupal.vbox.local/www/includes/bootstrap.inc:2172]
#11 drupal_bootstrap() called at [/vagrant/public/drupal.vbox.local/www/index.php:20]
So I suppose HHVM is not ready for PDO yet? I’d appreciate more input from people that are more knowledgable.
I think this is where my adventure with HHVM ends for now :-)