Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HHVM or PHP5 Zend running?

After some struggle, I finally installed Facebook HipHop Virtual Machine in Ubuntu. It is running under FastCGI (Apache 2.22). Below, the service status:

marcelo@marcelo-VirtualBox:~$ service apache2 status
Apache2 is running (pid 3330).
marcelo@marcelo-VirtualBox:~$ service hhvm status
 * hhvm is running
marcelo@marcelo-VirtualBox:~$ sudo service hhvm restart
 * Restarting HHVM FastCGI Daemon hhvm                                   [ OK ] 
marcelo@marcelo-VirtualBox:~$ 

The same machine has PHP5 module enabled and configured in Apache.


Question:

I want to make sure that I am really rendering PHP code using HHVM and NOT Zend Framework.

All my PHP scripts are running on the webserver. But, when I disable PHP5 module using sudo a2dismod php5 the web server starts to render Internal Server Error.

Does HHVM need PHP5 module enabled to run? Supposedly, since I am using FastCGI, my answer is no. On the other hand, I think that my pages are being rendered by Zend and not HHVM.

What am I missing here? How can I make sure that I am really running HHVM? (in my mind, a clear test is to disable PHP5 module, but, as I said, when I disable, php stops working in the web browser).

If .php is not running with PHP5 module disabled does it means that my HHVM is not properly configured?

P.S.: The script that I am testing is a default Hello World example: <?php echo 'Hello World.'; ?>.

And, It works when I run from command line:

marcelo@marcelo-VirtualBox:/var/www$ sudo hhvm hello_world.php
Hello World.
marcelo@marcelo-VirtualBox:/var/www$ 

EDIT

  • Apache error.log:

    marcelo@marcelo-VirtualBox:/var/log/apache2$ cat error.log [Wed May 07 14:02:10 2014] [notice] FastCGI: process manager initialized (pid 2627) [Wed May 07 14:02:10 2014] [notice] Apache/2.2.22 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations [Wed May 07 14:04:52 2014] [error] [client 127.0.0.1] (2)No such file or directory: FastCGI: failed to connect to server "/var/www/fastcgi/hhvm.fastcgi": connect() failed [Wed May 07 14:04:52 2014] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/var/www/fastcgi/hhvm.fastcgi" [Wed May 07 14:04:53 2014] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico marcelo@marcelo-VirtualBox:/var/log/apache2$

(Apparently, I should have 'hhvm.fastcgi' file. I only have the directory. Is anything wrong here?)

  • /var/www directory:

    marcelo@marcelo-VirtualBox:~$ ls -l /var/www total 20 drwxrwxrwx 2 root root 4096 May 6 23:45 fastcgi -rw-r--r-- 1 root root 31 May 6 21:57 hello_world.php -rw-r--r-- 1 root root 177 May 6 17:47 index.html -rw-r--r-- 1 root root 21 May 6 17:50 info.php -rw-r--r-- 1 root root 0 May 6 17:49 info.php~ drwxr-xr-x 13 997 1001 4096 May 6 18:13 mediawiki-1.22.6 marcelo@marcelo-VirtualBox:~$ ls -l /var/www/fastcgi/ total 0 marcelo@marcelo-VirtualBox:~$

- FastCGI configuration: I added the lines below, as suggested here: https://github.com/facebook/hhvm/wiki/FastCGI, at the end of apache2.conf file. In other words, after all 'mods-enabled' were already loaded.

# fastcgi added by M. Sardelich
<IfModule mod_fastcgi.c>
    Alias /hhvm.fastcgi /var/www/fastcgi/hhvm.fastcgi
    FastCGIExternalServer /var/www/fastcgi/hhvm.fastcgi -socket /var/run/hhvm/socket -pass-header Authorization -idle-timeout 300
    <Directory "/var/www/fastcgi">
        <Files "hhvm.fastcgi">
            Order deny,allow
        </Files>
    </Directory>

    AddHandler hhvm-hack-extension .hh
    AddHandler hhvm-php-extension .php

    Action hhvm-hack-extension /hhvm.fastcgi virtual
    Action hhvm-php-extension /hhvm.fastcgi virtual
</IfModule>
like image 229
Marcelo Sardelich Avatar asked Feb 14 '23 01:02

Marcelo Sardelich


2 Answers

To make sure that you are in fact running HHVM, run the following command:

phpinfo();

It should produce HipHop as the output, instead of the normal php info.

To check for it programmatically, you can use the following (also mentioned here):

if (defined('HHVM_VERSION')) {
    echo "ruuning HHVM";
}
like image 64
Sina Avatar answered Feb 19 '23 21:02

Sina


As correctly noticed (thanks @Petah), my FastCGI config was wrong.

I changed it to the snippet below (from here: http://www.mediawiki.org/wiki/HHVM/Vagrant) and everything is working! (add it to your apache2.conf or httpd.conf file)

<IfModule mod_fastcgi.c>
    Alias /hhvm.fastcgi /var/www/fastcgi/hhvm.fastcgi
    FastCGIExternalServer /var/www/fastcgi/hhvm.fastcgi -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
    <Directory "/var/www/fastcgi">
        <Files "hhvm.fastcgi">
            Order deny,allow
        </Files>
    </Directory>

    AddHandler hhvm-hack-extension .hh
    AddHandler hhvm-php-extension .php

    Action hhvm-hack-extension /hhvm.fastcgi virtual
    Action hhvm-php-extension /hhvm.fastcgi virtual
</IfModule>
like image 43
Marcelo Sardelich Avatar answered Feb 19 '23 23:02

Marcelo Sardelich