Hhvm: Getting 404 File Not Found on Apache 2.4, FastCGI and Ubuntu 14.04

Created on 14 Aug 2014  路  18Comments  路  Source: facebook/hhvm

My first step was install HHVM following this guide: https://github.com/facebook/hhvm/wiki/Prebuilt-packages-on-Ubuntu-14.04

Then i run the script with the command: 麓sudo /usr/share/hhvm/install_fastcgi.sh麓

Then i test if hhvm was installed with command 麓php -v麓 and the output is OK, says that HIPHOP VM is runing.

The problem arrives when i try to access to a PHP file, Apache always return 404 error. In the other hand html files and static files works good. I only receive 404 error with php files.

I search on Google and found many people with same issue but no solutions. Perhaps someone can help.

documentation

Most helpful comment

Do you directly access the php file? Like http://mysite.com/path/index.php not http://mysite.com/path/.
Does hhvm.server.fix_path_info help?

All 18 comments

I have exactly same problem, i have followed documentation instructions and i get error 404 with PHP files. Exists a solution?

Do you directly access the php file? Like http://mysite.com/path/index.php not http://mysite.com/path/.
Does hhvm.server.fix_path_info help?

Hi SiebelsTim,
i麓m accessing directly to the php file, something like http://127.0.0.1/test.php and i always get 404 error on php files. On the other hand, html files, images, etc... can be accessed OK.

Didn麓t explore hhvm.server.fix_path_info, don't know exactly what it do :/ (searching now)

Ok, i found this https://github.com/facebook/hhvm/issues/3285 and seems a bug that they not solved.

I tested it earlier today, it worked for me.
What are your settings in /etc/apache2/apache2.conf?

All other files probably can be accessed because apache handles them itself. Only PHP files should be sent to hhvm (ProxyPassMatch sets this)

I don't have the machine runing now, but i not modified /etc/apache2/apache2.conf bymyself at all, i simply run script sudo /usr/share/hhvm/install_fastcgi.sh as stated in documentation. Perhaps the bug was fixed in latest build, i will retry in a few hours and if the error continues i will post my config files contents.

Did you tryed on Ubuntu 14.04 x64?

Ok i tested and have exact same issues. My config files:
/etc/apache2/apache2.conf > https://gist.github.com/Zeokat/3b5c1273a7da48e1ad94
/etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf > https://gist.github.com/Zeokat/609b7313b8f9ab0ebe80
/etc/hhvm/php.ini > https://gist.github.com/Zeokat/bd05ca589d5581ff23f9
/etc/hhvm/server.ini > https://gist.github.com/Zeokat/f87002e5046f3a2fb3e2

I have no luck at all runing it and i have no idea what is wrong.

As SiebelsTim said, you could put "hhvm.server.fix_path_info = true" in /etc/hhvm/server.ini and restart hhvm with "/etc/init.d/hhvm restart".
I tested it today, it worked for me.

Thanks @filippouni i will test again but i think that i already tested that and didn't helped.

I got the same problems with 404 errors under Ubuntu 12.04 with Apache 2.2 and FastCGI. After i put "hhvm.server.fix_path_info = true" everything works fine.

The issue seems to be with /etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf - it overrides the proxy config in the vhost. Removing the whole file (symlink) and restarting apache made it work for me. You need a ProxyPassMatch or ProxyPass in your vhost though.

hhvm.server.fix_path_info = true is required if you use any mod_rewrite rule just FYI.

As the issue still persists for fresh installations on Ubunty 14.04 (x64), here is what worked for us when testing HHVM.

As removing "/etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf" from the system will result in PHP scripts not being served by HHVM, it is not a solution for the issue at hand.

Instead we had to do the following:

  1. Login to your server via SSH
  2. sudo nano /etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf
  3. Find:
    ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1

    Replace with:
    ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1

  4. Save the file (CTRL+X, y)
  5. Restart Apache (service apache2 restart)

Hope this is of any help :-)

@spamtrawler, it seems to me that hhvm_proxy_fcgi.conf sets a global proxypass. This might work on a single-site installation, but adding "html/" only makes that global proxy look in another directory - it still blocks any vhost config. Removing the file and setting ProxyPass directives locally (vhost conf) made it work for me.

I'm sure there is a more clean solution, but I havn't found it ...

So I had the exact same problem, tried all the suggestions here, but for some reason it still 404'd.

Thanks to #hhvm chat, I tried hhvm.server.fix_path_info = false and oddly, that worked for me (I do use _mod_rewrite_).
So if you're stuck too, give it a shot!

HipHop VM 3.7.0 (rel)
Compiler: tags/HHVM-3.7.0-0-gc8baf9cd3cb603e030969bfe24634d5e85549915

Also had this issue and had to do a mixture of steps:

  1. Delete /etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf
  2. Add ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1 to Apache site config
  3. Set hhvm.server.fix_path_info = false in /etc/hhvm/server.ini
  4. Restart both Apache and hhvm

Environment

$ uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ hhvm --version
HipHop VM 3.7.1 (rel)
Compiler: tags/HHVM-3.7.1-0-g111c76378ac29aa8f25e6bb3c5f15b628e6bbea1
Repo schema: be14a89778f35ca7f7dd4aca7fff0793e8ae3334

Setting HHVM with apache 2.4 running fastcgi:

nano /etc/apache2/mods-enabled/hhvm_proxy_fcgi.conf

comment this line

ProxyPassMatch ^/(.+.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1

Why did we comment that line? to avoid having it running globally on apache instead we are going to edit each virtualhost on apache to make it run by each virtualhost

Edit nano /etc/apache2/sites-available/virtualhost.conf

beginning of virtualhost file


ServerName example.com

    ServerAdmin [email protected]
    DocumentRoot /home/www/public_html
    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/www/public_html/$1

    ErrorLog /home/www/log/error.log
    CustomLog /home/www/log/access.log combined

    <Directory /home/www/public_html/>
            DirectoryIndex index.php
            AllowOverride All
            Require all granted
    </Directory>

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

end of virtualhost file

sudo service apache2 stop

sudo service hhvm stop

than

sudo service hhvm start

sudo service apache2 start

Thanks @SiebelsTim, hhvm.server.fix_path_info solved my issue here.

Looks like there's a resolution here. fix_path_info is now documented here: https://docs.hhvm.com/hhvm/configuration/INI-settings#common-options

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GDmac picture GDmac  路  3Comments

ahmadazimi picture ahmadazimi  路  7Comments

ezzatron picture ezzatron  路  7Comments

caioiglesias picture caioiglesias  路  6Comments

fredemmott picture fredemmott  路  3Comments