2014-01-06 34 views
4

我想通過Nginx使用HHVM。 (Ubuntu的LTS 12.04.2,PHP 5.3.10)HHVM與Nginx的fastcgi無法正常工作

我已經按照這裏提到的步驟:
http://www.hhvm.com/blog/1817/fastercgi-with-hhvm

這是我的Nginx設置的樣子:

server { 
     listen 80; 
     server_name demo1.dev 
     server_name_in_redirect off; 
     root /var/www/demo1; 
     location/{ 
       index index.php; 
       try_files $uri $uri/ @handler; 
       expires 30d; 
     } 
     location @handler { 
       rewrite//index.php; 
     } 
     location ~ .php$ { 
       fastcgi_keep_conn on; 
       if (!-e $request_filename) { rewrite//index.php last; } 
       expires  off; 
       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_param PHP_VALUE "error_log=/var/report/PHP.error.log"; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include  fastcgi_params; 
     } 
     location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
       expires 1y; 
       log_not_found off; 
     } 
} 

我有一個包含此文件的文件叫做hhvm.php:

function is_hhvm() { 
    return defined('HHVM_VERSION'); 
} 

if (is_hhvm()) { 
    echo "HHVM is working\n"; 
} else { 
    echo "HHVM is not working\n"; 
} 

我在做什麼錯誤以及如何查看HHVM是否正常工作?

UPDATE: 的輸出:ps auxf | grep hhvm

root  15164 0.0 0.0 9360 660 pts/0 S+ 13:55 0:00       \_ grep --color=auto hhvm 
www-data 15142 4.2 6.3 576564 122484 ?  Ss 13:54 0:01 /usr/bin/hhvm --config /etc/hhvm/server.hdf --user www-data --mode daemon 
www-data 15154 7.0 6.3 580668 122636 ?  Ss 13:54 0:01 /usr/bin/hhvm --config /etc/hhvm/server.hdf --user www-data --mode daemon -vServer.Type=fastcgi -vServer.Port=9000 -vPidFile=/var/run/hhvm/hhvm-fastcgi.pid 
+0

我似乎有一個類似的問題,但事實證明它與nginx無關http://stackoverflow.com/questions/21036910/debugging-in-nginx-yields-1-line-and-infinite-frustration - 如何調試-debu –

回答

10

一切看起來正確的。你可以嘗試使用php-fpm與完全相同的ngingx配置,看看它是否工作?也許你有一個目錄權限問題或什麼的。另外請確保你實際上是使用/etc/init.d/hhvm-fastcgi start開始hhvm-fastcgi進程,並且在運行之前沒有任何事情在端口9000上進行監聽。您可以運行ps auxf | grep hhvm以確保它正在運行並收聽。

+0

感謝您的明確答案。但我不知道如何讀取ps auxf。 HHVM在那裏雖然(見原始文章更新) –

+0

我有想法別的東西在端口9000上聽,我可以改變這個嗎? –

+3

是的,你可以把9000改成任何你想要的。確保更改ngingx配置,並更改/etc/init.d/hhvm-fastcgi –

3

在HHVM之前是否安裝了PHP5-FPM並在您的服務器上運行?

如果是的話,那麼你需要使用命令停止PHP5-FPM

service php5-fpm stop 

然後啓動/重新啓動HHVM

service hhvm restart 

如果你已經在你的web服務器的根目錄創建hhvm.php那麼該瀏覽使用任何瀏覽器的文件應輸出HHVM正在工作。

另外,您也可以使用FETCH和Google查看頁面的標題。如果標題是使用HHVM生成的,則標題將包含HHVM。

有關HHVM設置和故障排除的更多詳細信息,請參閱https://udinra.com/blog/hhvm-fastcgi-nginx-speedup-php