Getting Drupal 7 (almost) running on HHVM
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 # 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
Create a config file
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"
- 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 :-)
Comments
Hey there! I'm the person at
Hey there! I'm the person at Facebook who does the OSS maintenance for HipHop, and it's great to see you trying us out. ((Not so great to see that you got a segfault though)).
I'm going to try reproducing the segfault you're getting and will let you know what I find. Hopefully it's a minor problem. :)
D6 isn't much better. Strange
D6 isn't much better. Strange that there wasn't a php stacktrace...
<code>
Host: ubuntu-12
ProcessID: 8271
ThreadID: 52c48700
ThreadPID: 8279
Name: unknown program
Type: Segmentation fault
Runtime: hhvm
Version: heads/master-0-g5c736b05b0ec3289c11448c23b7893dfe47eeaff
URL: /install.php?profile=default&locale=en
ThreadType: Web Request
Server: 172.31.31.45:8000
# 0 ?? at hhvm:0
# 1 killpg at /lib/x86_64-linux-gnu/libc.so.6:0
# 2 void HPHP::VMExecutionContext::dispatchImpl<4>(int) at hhvm:0
# 3 HPHP::VMExecutionContext::dispatch() at hhvm:0
# 4 HPHP::VMExecutionContext::enterVMWork(HPHP::VM::ActRec*) at hhvm:0
# 5 HPHP::VMExecutionContext::enterVM(HPHP::TypedValue*, HPHP::VM::ActRec*, HPHP::VM::ExtraArgs*) at hhvm:0
# 6 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
# 7 HPHP::vm_call_user_func(HPHP::Variant const&, HPHP::Array const&, bool) at hhvm:0
# 8 HPHP::f_call_user_func_array(HPHP::Variant const&, HPHP::Array const&, bool) at hhvm:0
# 9 HPHP::UserSessionModule::close() at hhvm:0
# 10 HPHP::SessionRequestData::requestShutdownImpl() at hhvm:0
# 11 HPHP::BaseExecutionContext::onRequestShutdown() at hhvm:0
# 12 HPHP::hphp_context_exit(HPHP::ExecutionContext*, bool, bool, char const*) at hhvm:0
# 13 HPHP::HttpRequestHandler::handleRequest(HPHP::Transport*) at hhvm:0
# 14 HPHP::LibEventWorker::doJob(boost::shared_ptr<HPHP::LibEventJob>) at hhvm:0
# 15 HPHP::JobQueueWorker<boost::shared_ptr<HPHP::LibEventJob>, true, false>::start() at hhvm:0
# 16 HPHP::AsyncFuncImpl::threadFuncImpl() at hhvm:0
# 17 HPHP::AsyncFuncImpl::ThreadFunc(void*) at hhvm:0
# 18 start_thread at /lib/x86_64-linux-gnu/libpthread.so.0:0
# 19 __clone at /lib/x86_64-linux-gnu/libc.so.6:0
PHP Stacktrace:
</code>
Found this userful
Found this userful stackoverflow topic on this issue:
http://stackoverflow.com/questions/13636790/does-hhvm-hiphop-support-postgresql-arbitary-pecl-extensions
Hey guys,
Hey guys,
Worked through the wordpress example myself, and finally got it working. Not sure if you guys came across this:
http://php.webtutor.pl/en/2011/05/19/drupal-7-download-hiphop-for-phps-compatible-source-codes/
While it seems to have been compiled with a deprecated version of hiphop, there is a patch that theoretically works with Drupal 7.4? I was unable to get it working, but think maybe we could put together a vagrant box that does all the manual setup, and that might help us get on the same page with sorting this out?
And Sara Goleman, came across your blog while creeping on the project in general, and just wanted to say that you're awesome in all respects.
Any help would be really
Any help would be really appreciated.
Seems it now works a lot
Seems it now works a lot better, the problem now is stream_wrappers:
They seem to register but hhvm complains about not being able to create <your webroot>/public, that should translate to the public files dir.
Hey Nick, thanks for
Hey Nick, thanks for documenting this.
Tried this and didn't work (yet). Just saw that it's from 2012.
HHVM > 3.0.0 no longer supports built-in server, I'll try with FastCGI instead.