与Nginx同时运行hvm和PHP

与Nginx同时运行hvm和PHP,php,magento,nginx,hhvm,Php,Magento,Nginx,Hhvm,我一直在使用HHVM和Nginx运行一个magento站点。到目前为止,我没有遇到任何问题,我得到的只是一个非常受欢迎的显著性能提升 然而,我刚刚添加了一个插件,它使用了HHVM不支持的PHP函数。好消息是这个插件只需要一个页面。坏消息是,我没有正确配置Nginx,以便仅使用PHP提供此页面 在这种情况下,一些使用错误指令的人通常使用的回退技巧不起作用,因为页面不会抛出错误。如果启用了HHVM,它就是不起作用 相反,我尝试为特定页面编写许多不同的位置块。没有一个起作用,而这两个是我认为会起作用的

我一直在使用HHVM和Nginx运行一个magento站点。到目前为止,我没有遇到任何问题,我得到的只是一个非常受欢迎的显著性能提升

然而,我刚刚添加了一个插件,它使用了HHVM不支持的PHP函数。好消息是这个插件只需要一个页面。坏消息是,我没有正确配置Nginx,以便仅使用PHP提供此页面

在这种情况下,一些使用错误指令的人通常使用的回退技巧不起作用,因为页面不会抛出错误。如果启用了HHVM,它就是不起作用

相反,我尝试为特定页面编写许多不同的位置块。没有一个起作用,而这两个是我认为会起作用的

有没有办法只为特定页面运行PHP

失败的解决方案1

location  ~ /page/.+\.php${

    if (!-e $request_filename) { rewrite / /index.php last; }
    fastcgi_pass   unix:/var/run/php5-fpm.sock; ##Unix socket
    fastcgi_param  HTTPS $fastcgi_https;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;      
}

location ~ \.(hh|php)$ {

    if (!-e $request_filename) { rewrite / /index.php last; }
    fastcgi_keep_conn on;
    fastcgi_pass unix:/var/run/hhvm/sock;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS $fastcgi_https;
    include        fastcgi_params;
}
失败的解决方案2(具有嵌套位置)


尝试使用可变条件方法,它对我很有效,从
/serve with php/
开始的位置使用
unix:/var/run/php5 fpm.sock
,而所有其他位置都使用
127.0.0.1:9000

server {
    root /home/vearutop/test-hhvm;
    index index.php index.html index.htm;
    error_log /var/log/nginx-error.log error;
    charset        utf-8;

    server_name test-hhvm;

    location / {
        set $fcgi_worker 127.0.0.1:9000; # hhvm handle
        try_files $uri $uri/ /index.php?$query_string;
    }


    location /serve-with-php/ {
        set $fcgi_worker unix:/var/run/php5-fpm.sock; # php-fpm handle
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass $fcgi_worker;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

非常感谢。这确实起作用。我唯一的问题是,我的位置最好需要正则表达式,
location/
似乎总是排在前面。除此之外,它工作得很好。我还使用了
fastcgi\u keep\u conn on位于
\php$
位置,因为HHVM似乎需要它。到目前为止没有冲突
server {
    root /home/vearutop/test-hhvm;
    index index.php index.html index.htm;
    error_log /var/log/nginx-error.log error;
    charset        utf-8;

    server_name test-hhvm;

    location / {
        set $fcgi_worker 127.0.0.1:9000; # hhvm handle
        try_files $uri $uri/ /index.php?$query_string;
    }


    location /serve-with-php/ {
        set $fcgi_worker unix:/var/run/php5-fpm.sock; # php-fpm handle
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass $fcgi_worker;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}