april breeze

another web programmer

photo gallery

NGINX + HHVM (FastCGI) + Laravel

설치 등등은 http://fideloper.com/hhvm-nginx-laravel 여기 잘 정리돼있고, 위 링크의 nginx 설정에는 /index.php?q=$uri&$args 로 넘기도록 돼있는데 q= 으로 넘기는 방식이 왠지 맘에 안들어서 아래처럼 수정했음.

server {  
    root /path/to/document/root;
    index index.html index.php;

    server_name site.com *.site.com;

    location / {
        # from Laravel .htaccess
        # https://github.com/laravel/laravel/commit/ce64714b2fda6d6a14ea6649a03aa59bfbd6d079
        rewrite ^/(.*)/$ /$1 redirect;

        try_files $uri @proxy;
    }

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml|svg|swf)$ {
        access_log  off;
    }

    # hhvm.conf
    location ~ \.php$ {
        try_files $uri @proxy;
        fastcgi_keep_conn on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location @proxy {
        fastcgi_keep_conn on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root/index.php;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
comments powered by Disqus