hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Apache 2.2 Support

Open TheRyanHowell opened this issue 12 years ago • 13 comments

The current documentation for using Apache as a front end seems to be directed to Apache 2.4, as the mod_proxy_fcgi module isn't available in 2.2.

Please could you give some documentation on the recommended setup for Apache 2.2, or update the current documentation if you don't plan on supporting this version of Apache.

The main reason for me still wanting to use Apache 2.2 is mod_spdy, however Facebook seems to use mod_spdy as well, if that's available in HHVM?

Thanks

TheRyanHowell avatar Mar 21 '14 19:03 TheRyanHowell

+1

franz-deleon avatar Mar 21 '14 20:03 franz-deleon

@apuckey do we work on Apache 2.2?

ptarjan avatar Mar 21 '14 22:03 ptarjan

We do indeed. I will add some documentation when I get home from breakfast :-)

apuckey avatar Mar 21 '14 22:03 apuckey

Yay, thanks so much @apuckey

ptarjan avatar Mar 21 '14 23:03 ptarjan

Ok i added some documentation for apache 2.2 and seperated out the 2.4 docs.

https://github.com/facebook/hhvm/wiki/FastCGI

apuckey avatar Mar 22 '14 00:03 apuckey

thank you @apuckey . i was pulling my hair all day to figure this out

franz-deleon avatar Mar 22 '14 01:03 franz-deleon

I'm still pulling my hair here :). I've some questions:

What is this "/path/to/hhvm.socket" How do I know where 'my' socket is? Also this file: "/var/www/fastcgi/hhvm.fastcgi". Who or which process creates this?

I'm trying to use this in a virtual host, is this the way to go or do I need other stuff too?

timing avatar Mar 22 '14 13:03 timing

@timing you can try to replace -socket with -host 127.0.0.1:9000 if it doesnt work. also make sure to disable the apache php module. you can add this in a virtualhost i believe but for me i just added it in etc/apache/httpd.conf

and of course you need to run hhvm fastcgi...hhvm -m server -c /etc/hhvm/server.ini worked for me

franz-deleon avatar Mar 22 '14 14:03 franz-deleon

@franz-deleon Ok I have hhvm running like this, presuming the default config is ok

hhvm --mode server -vServer.Port=9001

This is my vhost config:

<VirtualHost *:80>                                                                                                                                            
    ServerName example.com                                                                                                                                     
    ServerAlias www.example.com                                                                                                                                

    DocumentRoot /home/tijmen/sites/example.com                                                                                                                

    php_value engine off                                                                                                                                      

    #<IfModule fastcgi_module>                                                                                                                                
        Alias /hhvm.fastcgi /home/tijmen/sites/example.com/hhvm.fastcgi                                                                                        
        FastCGIExternalServer /home/tijmen/sites/example.com/hhvm.fastcgi -host 127.0.0.1:9001                                                                 
        <Directory "/home/tijmen/sites/example.com/">                                                                                                          
            <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>                                                                                                                                              

    ErrorLog /home/tijmen/sites/log/example.com-error.log                                                                                                      

    # Possible values include: debug, info, notice, warn, error, crit,                                                                                        
    # alert, emerg.                                                                                                                                           
    LogLevel debug                                                                                                                                            

    CustomLog /home/tijmen/sites/log/example.com.log combined                                                                                                  


</VirtualHost>

In none of the logfiles (apache, error log, hhvm log) there is something which gives a hint as what is wrong.

example.com/index.hh just gives a 404.

Not sure how to disable the php module for this virtualhost, but I found this php_value solution somewhere.

timing avatar Mar 22 '14 15:03 timing

@timing I have this configuration. it is pretty much the same as in the official docs

<IfModule mod_fastcgi.c>
    Alias /hhvm.fastcgi /vagrant/www/fastcgi/hhvm.fastcgi
    FastCGIExternalServer /vagrant/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>

all of my projects in /vagrant/www/* forwards to hhvm fastcgi this way. Also i do have this folder existing /vagrant/www/fastcgi and i dont see any file name hhvm.fastcgi there.

I think you may need to change this:

<Directory "/home/tijmen/sites/bpmtab.com/">                                                                                                          
            <Files "hhvm.fastcgi">                                                                                                                            
                Order deny,allow                                                                                                                              
            </Files>                                                                                                                                          
        </Directory> 

to:

<Directory "/home/tijmen/sites/example.com">                                                                                                          
            <Files "hhvm.fastcgi">                                                                                                                            
                Order deny,allow                                                                                                                              
            </Files>                                                                                                                                          
        </Directory> 

i disable the php module using command line

$> sudo a2dismod php5

or you can just disable the configuration in /etc/apache2/mods-enabled

this is also a good read: http://whocares.de/fastcgiexternalserver-demystified/all/1/

franz-deleon avatar Mar 22 '14 23:03 franz-deleon

@timing you need to start hhvm like this for fastcgi mode otherwise it wont talk fastcgi:

replace --mode server mode with --mode daemon to make it go to the background as well.

TCP Mode:

hhvm --mode server -vServer.Port=9001 -vServer.Type=fastcgi

Socket Mode:

hhvm --mode server -vServer.FileSocket=/path/to/socket.sock -vServer.Type=fastcgi

apuckey avatar Mar 23 '14 00:03 apuckey

@franz-deleon The hostname difference was an edit fault when writing the comment. Sorry about that. So the way I put the fastcgi config in the vhost is OK? Or do I have to make this config global?

@apuckey I've used various way of starting the hhvm server. Including passing the Type, to no avail.

I've also asked my question on ServerFault. In case you guys want some reputation points there :)

http://serverfault.com/questions/583866/setting-up-hhvm-for-apache2-2-with-mod-fastcgi-in-a-virtual-host

timing avatar Mar 23 '14 13:03 timing

@timing you almost certainly need to pass the type every time. if you do not then it will start up its own webserver and not talk fastcgi.

What version of hhvm are you using ?

can you create a config file like this in /etc/hhvm/hhvm.hdf

Server {
  Port = 9000
  Type = fastcgi
}
Log {
  Level = Trace
  UseLogFile = true
  Header = true
  File = /var/log/hhvm/error.log
  Access {
    * {
      File = /var/log/hhvm/access.log
      Format = %{X-Forwarded-For}i %l %u %t %v \"%r\" \"%{User-agent}i\" %>s %b %D
    }
  }
}
Eval {
  Jit = true
  EnableHipHopSyntax = true
}

make sure /var/log/hhvm exists and is writeable by the user you are starting hhvm as then start the server like:

hhvm --config /etc/hhvm/hhvm.hdf --mode server

make sure you have:

FastCGIExternalServer /home/tijmen/sites/example.com/hhvm.fastcgi -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300

then restart apache and do a request and see what comes out in /var/log/hhvm/error.log

i am on irc now for the next ~8hrs so would be easier to discuss this on there :-)

apuckey avatar Mar 23 '14 22:03 apuckey