Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hiphop-php HHVM working with Codeigniter and Nginx
I managed to make Codeiniter work with HHVM, using
nginx as a proxy. My problem was that hhvm has problems
with path_info, so I was not able to run /index.php/controller/action or
/controller/action/params -> /index.php/controller/action.params.
I used nginx as a proxy to hhvm. I changed the way codeigniter process
the url. Steps bellow:
Cleaned my HHVM .hdf file:
Server {
Port = 9000
SourceRoot = /usr/share/nginx/www/mysystem
}
VirtualHost {
* {
Pattern = .*
}
}
Configure Nginx:
server {
server_name mymachine;
root /usr/share/nginx/www/mysystem;
index index.php index.html index.htm;
proxy_redirect off;
# Copy request_uri to variable $myuri before processing
set $myuri $request_uri;
location / {
# Check if a file exists, or route it to index.php.
try_files $uri $uri/ /index.php;
}
# Send *.php to Hiphop hhvm
location ~ \.php$ {
proxy_set_header MY_SCRIPT $myuri;
proxy_pass http://127.0.0.1:9000;
}
}
Changed Codeigniter file /application/config/config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'HTTP_MY_SCRIPT';
Restart eveything and it is working for me
@kyleboddy

This comment has been minimized.

Copy link

@kyleboddy kyleboddy commented May 2, 2013

This is exactly what I'm looking for! I get it running and can load index.html files, but when I try to load a simple hello.php file (much less a CodeIgniter directory/controller), I get "Not Found" errors with nothing in the error.log file.

Any ideas? Thanks so much. Been trying to get this working for a long time!

EDIT: Never mind, got it working. It only works in a CI root directory. Thank you!

@tbranch227

This comment has been minimized.

Copy link

@tbranch227 tbranch227 commented Sep 16, 2013

So, what's the performance like?

@thibautrey

This comment has been minimized.

Copy link

@thibautrey thibautrey commented Jan 21, 2014

Sounds great. Does anyone know how to port that to heroku ?

@mhamzas

This comment has been minimized.

Copy link

@mhamzas mhamzas commented Apr 18, 2014

I made it work without any special conf

@bs-thomas

This comment has been minimized.

Copy link

@bs-thomas bs-thomas commented Jul 14, 2014

Yeah I'm wondering about the performance too. Is it much better on HHVM?

Also, has the path_info problem been resolved?

@X17

This comment has been minimized.

Copy link

@X17 X17 commented Jan 2, 2015

Has anyone cracked it yet? how does it affects?

  • performance
  • url structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment