Friday, November 14, 2014

Magento on HHVM 3.3 Nginx 1.6 on Ubuntu 14.04 trusty

No more Varnish! Love HHVM!

1.First this VPS box running Ubuntu 14.04 trusty 64 bit with 2 GB Memory and 2 Core CPU.
Please follow HHVM, Nginx and MariaDB 's offical installation guide to install:

After installation I have these files under /etc/apt/sources.list.d/:
deb trusty nginx

deb trusty main

deb trusty main

At this moment I have the version:

root@mds-magento:/var/www/magento/includes# dpkg -l|grep hhvm
ii hhvm 3.3.0~trusty amd64 HHVM virtual machine, runtime, and JIT for the PHP language
root@mds-magento:/var/www/magento/includes# dpkg -l|grep nginx
ii nginx 1.6.2-1~trusty amd64 high performance web server
root@mds-magento:/etc/apt/sources.list.d# dpkg -l|grep mariadb
ii libmariadbclient18 10.0.14+maria-1~trusty amd64 MariaDB database client library
ii mariadb-client-10.0 10.0.14+maria-1~trusty amd64 MariaDB database client binaries
ii mariadb-client-core-10.0 10.0.14+maria-1~trusty amd64 MariaDB database core client binaries
ii mariadb-common 10.0.14+maria-1~trusty all MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
ii mariadb-server 10.0.14+maria-1~trusty all MariaDB database server (metapackage depending on the latest version)
ii mariadb-server-10.0 10.0.14+maria-1~trusty amd64 MariaDB database server binaries
ii mariadb-server-core-10.0 10.0.14+maria-1~trusty amd64 MariaDB database core server files

2.Share my Nginx config file:

user www-data;
worker_processes 2;

error_log /var/log/nginx/error.log warn;
pid /var/run/;

events {
worker_connections 1024;

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
autoindex off;
#tcp_nopush on;

map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;

keepalive_timeout 10;

gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript application/xml application/xml+rss text/javascript;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;


location ~ .(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;


server {
listen 80;
server_name localhost;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www

server {
listen 80 default;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

root /var/www/magento;

location / {
index index index.html index.htm index.php;
try_files $uri $uri/ @handler;

## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }

location /. { ## Disable .htaccess and other hidden files
return 404;

location @handler { ## Magento uses a common front handler
rewrite / /index.php;

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;

location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

expires off; ## Do not cache dynamic content
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params

3.My HHVM config file:


; php options

pid = /var/run/hhvm/pid

; hhvm specific

;hhvm.server.port = 9000
hhvm.server.file_socket = /var/run/hhvm/hhvm.sock
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc


; php options

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false

Thank you for the kind sharing from: